A teenage girl named Hazel Grace Lancaster (Shailene Woodley) is lying in the grass staring up at the stars. She states that she believes we're allowed to choose how to tell sad stories, and that although one can sugarcoat it and say there's nothing that can't be fixed with a Peter Gabriel song, it's not the truth.
Hazel suffers from stage 4 thyroid cancer and is always seen carrying an oxygen tank with a cannula in her nose for her to breathe. At the behest of her mother Frannie (Laura Dern), father Michael (Sam Trammell), and her doctor Maria (Ana Dela Cruz), she attends a cancer support group at a church called the Literal Heart of Jesus. The person running it is a man named Patrick (Mike Birbiglia), who had testicular cancer and is now divorced and lives with his parents, but is positive because he is alive. Frannie wants Hazel to make friends, but as Hazel says, the only thing worse than biting it from cancer is having a kid that bites it from cancer.
One day during her trip to the group, Hazel bumps into Augustus Waters (Ansel Elgort). During the meeting, Gus stares at Hazel. Patrick first calls on Gus's friend Isaac (Nat Wolff), who had a tumor in his eye and now wears a glass eye, though he is thankful because of his "smoking hot" girlfriend Monica. When Gus is called on, he says that he has been in remission from osteosarcoma after having his right leg amputated (he wears a prosthetic). Patrick asks him if he has any fears, and Gus states that he fears oblivion. Hazel shoots this down by saying that eventually, everything and everyone will be gone and forgotten, and if that scares him, he should ignore it. After the meeting, Hazel waits for her mom, and Gus comes out to chat with her. They see Isaac and Monica making out and groping each other, then repeating "Always" to one another. Gus explains to Hazel that this is their way of saying they'll always love each other. He asks Hazel her name and tells her she's beautiful. He then puts a cigarette in his mouth, which upsets Hazel because it has ruined her impression of him. Gus explains that he never smokes the cigarettes he puts between his teeth so as to not give the killing item any power. He invites Hazel to come over and watch a movie.
While Gus recklessly drives to his house, he asks Hazel about her cancer story. She tells him (through flashbacks) that she was diagnosed when she was 13 and went through all the required treatment, but it wasn't working. Her lungs began to fill with water and she was treated in the ICU. Then one day, the medication she was given began to work well, which was considered to be miraculous. Hazel and Gus arrive at his home and meet his parents. He brings Hazel to the basement and asks her to tell him her real story, not her cancer story. She claims to be unremarkable, but he rejects that. He gives her a copy of his favorite book based off his favorite video game, "Counterinsurgence". Hazel, in return, recommends her favorite book, "An Imperial Affliction", which is about a girl that has leukemia, but she tells Gus that it is not necessarily a cancer story.
Hazel waits for Gus to call her back, and after a few days, he texts her after finishing "An Imperial Affliction". He expresses surprise that the book ends mid-sentence (the protagonist Anna apparently dies during her narration). Hazel excuses herself from dinner to speak to Gus on the phone, but they are interrupted by Isaac wailing a song lyric in the background. Gus invites Hazel over, where she finds out that Monica broke up with Isaac, and he is having a psychotic episode. Gus allows Isaac to take out his anger on his basketball trophies. While Isaac smashes them, Gus talks to Hazel about the ending of the book, and she tells him that she has written hundreds of letters to ask the book's author, Peter Van Houten, questions about what happened after the story, such as the fate of Anna's mother and her relationship with the "Dutch Tulip Man", and Anna's pet hamster Sisyphus.
One evening during a phone conversation, Gus tells Hazel that he tracked down Van Houten's assistant and got a response from a message he wrote to him. Van Houten thanked Gus for his and Hazel's interest in the novel, and that he has no current plans to write any follow-ups to "An Imperial Affliction". Hazel is surprised that it took that one e-mail to get a response. She decides to write her own e-mail back to Van Houten to ask the questions. A few days later, Hazel gets her own response from Van Houten, who also thanks her for her interest in the story, and even invites her to visit him in Amsterdam. Overjoyed, Hazel tells her mother, and while she wants to make her daughter happy, she knows she wouldn't be able to afford it. Hazel later reads the e-mail to Gus, and they stay talking until 1:00 AM. Hazel decides it's time to hang up. "Okay," Gus responds. "Okay," Hazel says back. Gus decides that "Okay" can be their "Always".
Hazel tells Gus about the invitation, and Gus suggests asking the Genies (a Make-A-Wish sort of organization) to grant her this wish. Hazel states that she already used her wish to go to Disney World. Gus is disappointed that she used her wish on a cliche. A while later, Gus shows up at Hazel's home with flowers, and then invites her on a picnic to a park featuring a giant skeleton playground called Funky Bones. Gus jokes that he has brought all his romantic conquests here and that is why he is a virgin. He even illustrates this by drawing a circle in the dirt of virgins and a small circle within of 18-year-old boys with one leg. As they have their picnic, Gus tells her that he spoke to the Genies and convinced them to grant him the wish of taking Hazel to Amsterdam. She is ecstatic.
Hazel wakes up in the middle of the night having trouble breathing as fluids fill her lungs. Her parents rush her to the hospital, with Gus waiting outside since he is not allowed in (family only). Hazel has the fluids drained from her lungs and she recovers. After a meeting with the doctors, they determine that she is physically unfit to travel anywhere in her condition. Hazel then has a flashback to when she was in the ICU as a child with Frannie telling her she can let go, and then sobbing to Michael that she won't be a mom anymore.
Feeling dejected, Hazel sits in front of a swingset in the backyard that her father built when she was a child. She calls Gus and expresses her sadness. He comes over and they sit on the swings. He tells her that her keeping her distance from him does not lessen his affection toward her. She compares herself to a grenade and that she will blow up and destroy everything in her wake. Not wanting to hurt Gus, Hazel decides they ought to remain friends.
Days later, Van Houten's assistant Lidewij e-mails Hazel to extend the invitation again after learning that they will be traveling to Amsterdam in a week. Hazel calls her mother in, and she admits that she wanted to surprise her, but they are indeed going to Amsterdam. Hazel hugs Frannie and then texts Gus. He replies, "Everything is coming up Waters!" She then looks down at her lungs and tells them to keep their shit together.
Gus arrives in a limo to pick up Hazel and Frannie, declaring he wants to travel in style. On the plane, Gus becomes nervous as he's never ridden on a plane before, but he becomes excited once they take off.
On their first day in Amsterdam, Hazel and Gus ride through a canal and go to a Dutch restaurant, Oranjee. Hazel wears a cute blue dress given to her by Frannie. Gus is stunned by how beautiful Hazel looks. At the restaurant, they are served Dom Perignon and they enjoy it. They have their dinner, and Gus proudly declares his love to Hazel, which puts a big smile on her face. The waiter comes by with more champagne, and he says the dinner was all paid for by Van Houten.
The next day, Hazel and Gus go to meet Van Houten. They are greeted at the door by Litewij (Lotte Verbeek), who welcomes them inside. There is unopened fan mail all over the floor. The couple finds Van Houten (Willem Dafoe) in his pajamas, drinking scotch. They sit down so Van Houten can answer their questions, but he instead plays Swedish rap. Hazel starts to ask questions, such as the fate of Anna's mother and the Dutch Tulip Man, but Van Houten only responds with philosophical nonsense. Gus asks him if he's messing with them, and Van Houten makes a rude comment about Gus's cancer. He only gets worse by refusing to answer Hazel's questions and insulting her and Gus's sicknesses. Hazel and Gus storm out. Van Houten asks her why she dwells on these questions, and Hazel just tells him to go fuck himself.
Lidewij, appalled by Van Houten's behavior, escorts Hazel and Gus to the Anne Frank House. Since there are no elevators, Hazel must walk up all the stairs and climb the ladder, which puts a strain on her breathing. They get up to the floor with a vocal recording of Anne Frank's diary. As the voice talks about capturing beauty, Hazel and Gus share their first kiss. The onlookers, including Litewij, applaud them. They go back to Gus's room and make love for the first time. Hazel leaves him with a drawing of the large virgin circle, and the circle of 18-year-old boys with one leg outside that big circle.
On their last day, Hazel and Gus have breakfast with Frannie before walking alone together. They sit on a bench and Gus tells her that when she was in the ICU, he felt a pain in his hip and got a PET scan. Hazel already knows what he's going to tell her. Gus says the scan "lit up like a Christmas tree", and the cancer returned and spread through his body. Hazel puts her head on his shoulder and cries. Gus tries to lighten the mood by suggesting they make out.
Hazel, Gus, and Frannie return to Indianapolis with Michael picking them up. A few days later, Hazel and Gus hang out with Isaac, who is now completely blind and tells them that Monica hasn't spoken to him since the break-up. To cheer him up, Hazel and Gus buy eggs, and they go to Monica's home and pelt her car with eggs.
Gus calls Hazel in the middle of the night to ask her to come to the gas station to help him. She drives over there to find him sitting in his car, covered in his own mucus and vomit, with an infection in his abdomen from the G-tube. Hazel starts to call for an ambulance, despite Gus's pleas. The ambulance arrives and takes Gus away.
Gus undergoes more treatment for the cancer until the doctors decide to take him off the chemo. He now requires a wheelchair to get around. Hazel takes him to Funky Bones for a picnic. He expresses his desires to have left an impact on the world before he dies and his need to live an extraordinary life. Hazel takes offense to it and tells him that he doesn't need to do all that because she and his parents love him and that it should be enough. He says he's sorry and they drink champagne.
Gus calls Hazel another evening to invite her to the Literal Heart of Jesus for a gathering, and to bring a eulogy that he asked Hazel to write for him. She starts to leave but is stopped by her parents who are setting up dinner. Hazel argues with them that she will be gone and that they will be alone after hearing her mother say she won't be a mom anymore after Hazel dies. Both her parents say they will never stop loving her no matter what happens, and that Frannie is taking classes to become a speaker. Hazel becomes happy that her parents will be fulfilled even after she is gone.
Hazel joins Gus and Isaac at the church for what is a "pre-funeral" for Gus, since he wants to attend his own funeral. Isaac starts off a eulogy with a touch of humor, but says that if he ever is given "robot eyes", he would deny them because he doesn't want to see a world without Gus. Hazel goes up and starts to talk about her love story with Gus before saying that there are infinite numbers between 1 and 0, and that there are countless infinities, and that she is thankful for their infinity. They both say "I love you" to each other one last time.
Gus dies eight days later. The Lancasters receive a phone call in the middle of the night to hear the news. Hazel's parents walk into her room, and without a word, she knows what it is and she begins to cry. She recalls a time when undergoing treatment and the nurse asked her to rate her pain on a scale from 1 to 10. Hazel said 9, and the nurse said she was a fighter for calling a 10 a 9. She says that she was saving her 10 for this sort of occasion.
A funeral is held for Gus. Hazel and her parents go, and as the preacher speaks, Hazel is surprised to see Van Houten there. Hazel is called up to speak and gives a new eulogy. After the funeral, Hazel decides to drive home alone, and Van Houten enters her car. There, she learns that he and Gus kept in touch prior to his death, and Gus told Van Houten that he could redeem himself by visiting Hazel and answering her questions. He reveals that Anna was based off Van Houten's 8-year-old daughter who died of leukemia. Before she sends him out of her car, Van Houten gives Hazel a letter, which she crumples up and throws away. She drives away and sees him drink from his flask.
Hazel's dad goes to comfort her following Gus's death. Later, Isaac goes over to visit. He tells Hazel that Gus really loved her and never stopped talking about her to the point where it got annoying. He asks her if she read the letter from Van Houten, which happened to be written by Gus.
The letter is a eulogy for Hazel written by Gus. We hear Gus's voice reading it, saying that he saw Hazel in the ICU while she slept, and how he thought about them together. He expresses his admiration for her beauty and personality, and adds that people can choose who hurts them. Gus liked his choice, and he hoped Hazel liked hers. He closes it with "Okay, Hazel Grace?"
The film ends with Hazel still looking up at the stars, replying, "Okay."