Eighteen-year-old Mateo is scrolling through a blog called CountDowners at 12:22 a.m. when he gets a call from Death-Cast, an organization that gives people 24 hours’ notice of their death. His herald, Andrea, carelessly mixes him up with the last Decker that she called, so Mateo hangs up. He panics—he’s an anxious person and has few friends, and he already misses the Mateo of the future. Future Mateo would get out there and live. Mateo vows to leave his apartment so he can see Dad (who’s in a coma in the hospital), his best friend Lidia, and Lidia’s daughter Penny before he dies. A half hour later, 17-year-old Rufus is in the middle of beating up a boy named Peck for stealing his girlfriend when he gets his own call from Death-Cast letting him know he’s going to die today. Rufus’s herald, Victor, is kind, but this doesn’t help—Rufus doesn’t want beating someone to be his last act. He heads back to his foster home with his best friends and foster siblings, Malcolm and Tagoe, for his funeral. Rufus calls his ex-girlfriend (and former foster sister), Aimee, on the way home. She agrees to meet the boys at the foster home, but she brings Peck with her. Though Rufus’s funeral starts out tearful and meaningful, the police arrive—Peck called them. Malcolm and Tagoe hold off the police while Rufus sneaks out the back and rides away on his bike.
Mateo decides that he wants his headstone to read, “He Lived for Everyone,” and then he downloads the Last Friend, an app designed to help Deckers find friends on their End Day (their last day alive). He doesn’t want to tell Lidia he’s dying, so he needs someone to coach him through the day. He chooses a photo of him wearing a Luigi hat as his profile picture, since he wants to be the kind of person who wears silly hats and sings in front of people. The first few people he talks to are rude or callous. At the same time, Rufus sits down next to graffiti advertising Last Friend and decides that since he doesn’t have his friends, he can make a new one. He and Mateo connect immediately, begin video chatting, and Rufus agrees to go to Mateo’s apartment and pick him up. Both boys are nervous. Mateo grabs a photo of Dad and himself as a kid, leaves notes for the neighbors, and follows Rufus out of the building.
There’s a dead bird in the street, and Mateo insists they bury it. Rufus, an active Instagrammer, takes a photo of Mateo burying the bird. He thinks Mateo is too good and follows Mateo to the subway. Rufus gets into a train car where people are partying; Mateo gets in a different car and insists they have no business celebrating. They get off at the hospital. Mateo already feels bad about not breaking out of his shell. In Dad’s room, Mateo feels angry—Dad was there on the day that Mateo’s mom died giving birth to him, and Dad should be awake now. He tells Dad’s nurse, Elizabeth, about how his parents got engaged and then tries to tell Dad a secret. He can’t voice it, but he leaves Dad the photo of them and a note promising that he was brave. Rufus leads him out of the hospital. They pass a homeless man, and Mateo insists on giving the man money since they won’t need their money anymore after today. At around the same time, a young reporter named Delilah tells herself that her ex-fiancé, the Death-Cast employee Victor, is messing with her—she’s not actually going to die. She learns that the movie star Howie Maldonado is going to die today, and she vows to report on his death.
Since it’s too early to visit Lidia, Mateo and Rufus decide to get breakfast at Rufus’s favorite cafe. The waitress, Rae, is shocked that Rufus and Mateo are Deckers and tries to give them their meal for free, but Mateo insists on paying. He and Rufus discuss what they wanted to be when they grew up, and Rufus draws the world—he wanted to travel and take pictures. After their meal, Mateo refuses to ride on the back of Rufus’s bike to Lidia’s, so they walk to her apartment. Mateo explains why he doesn’t want to tell Lidia he’s dying: her boyfriend, Christian, died right before Penny was born. Lidia slept through Christian’s attempts to reach her, and Mateo doesn’t want to hurt her even more. Rufus stays downstairs as Mateo goes up and helps Lidia tidy up and feed Penny. He tells Lidia that she’s amazing, and when Lidia leaves the room, Mateo drops an envelope of cash and sneaks away. He blocks Lidia’s number. Outside, Rufus encourages Mateo to take comfort in the fact that he’s getting to say goodbye. Mateo encourages Rufus to post colorful photos on Instagram from his final day so that Rufus’s friends have something to remember him by.
Rufus calls Aimee, and Mateo hears that Malcolm and Tagoe are in jail. Terrified of Rufus, Mateo runs away—but Rufus hangs up on Aimee, who won’t break up with Peck, and chases after Mateo. Rufus agrees to tell Mateo everything in Central Park. He shares that he’s been in foster care for the last five months after he was in a car crash in which his parents and older sister, Olivia, drowned in the Hudson River. He beat up Peck last night because he felt like he’d never amount to anything. Mateo knows that Rufus isn’t a monster, and he invites Rufus to go with him to a Make-A-Moment station. A humorless woman named Deirdre checks them in and gets them set up to do virtual skydiving. The experience costs $240 each, and after the fact, the boys agree that it was a weird experience. Rufus leads Mateo to a payphone graveyard where they talk about Indiana Jones and about how Mateo gave his shoes to a kid who had none a year ago. The narrator introduces a boy named Kendrick, who isn’t dying today—but a year ago, some kids jumped him and stole his shoes. A stranger (Mateo) gave Kendrick his shoes—but now, Kendrick just wants to punch people.
Delilah begs her boss, Sandy, to let her interview Howie. Sandy grudgingly agrees that Delilah can come along, and she sends Delilah to buy a copy of Howie’s first book. Meanwhile, Mateo asks if they can visit his mom’s grave. Rufus buys some Legos for Mateo before they get on the subway, and when the train temporarily loses power, Mateo builds a sanctuary with the Legos. He falls asleep as Rufus keeps watch and takes a photo of Mateo sleeping. As the boys walk through the cemetery, they discuss what they think the afterlife is like. Mateo stops dead when he gets close to his mom’s grave: someone is digging Mateo’s grave next to it. Rufus yells at the man to go away. Mateo sits with his mom, thinks about his birth, and then sits in his unfinished grave with Rufus. As the boys talk, they realize that they both have strong memories associated with Althea Park. Next, Mateo leads Rufus to a pier so that Rufus can get closure from his parents’ deaths. Surprisingly, this works. Mateo and Rufus stop in at a bookstore, where Mateo purchases postcards and a mystery book wrapped in paper. Outside, a Decker named Vin sets a suicide bomb off, killing other Deckers and hurting Rufus, Mateo, and Delilah. Rufus decides he has to ride his bike, and Mateo finally agrees to ride on the back.
As Rufus bikes, he unwittingly rides past the apartment building that Deirdre, the woman from Make-A-Moment, is standing on. She’s prepared to kill herself because her job makes her feel like life is pointless—however, seeing Rufus and Mateo down below makes her decide to live. When the boys get to Althea Park, Mateo jumps off the bike, thrilled that he took a risk. They’re both even more afraid of dying after seeing so many die from the bomb. They play a game on the monkey bars, and then Rufus gives his bike to a guy who recently wrecked his—he won’t need it anyway. At the same time, Peck calls his friend Damien. They decide to get the gang back together and get justice for Peck by killing Rufus. Peck digs out his gun and stares at Rufus’s Instagram, waiting for Rufus to reveal his location.
Rufus and Mateo decide to ride the subway. They play a game where they make up stories about fellow passengers, and then they pretend that they’re living out their future together. In their hypothetical narrative, Rufus works in a building that Mateo built, and they’ve gotten tattoos together. Mateo decides to leave his wrapped book for someone else, and the boys hop off the train. Two girls get on and find the book. One, Zoe, is a Decker; the other, Gabriella, leaves graffiti for Last Friend around the city (which is what inspired Rufus to download the app). Mateo calls Lidia and invites her to join them at the Travel Arena, and Lidia arrives soon after. Her ticket costs $100, but Mateo and Rufus’s admission is free. They take the Around the World in 80 Minutes tour, and Rufus insists they get off the trolley in faux Puerto Rico. He leads them to an attraction called the Rainforest Jump, where Mateo convinces Rufus and Lidia to join him in leaping off a 20-foot cliff. Rufus feels as though he’s been baptized and has left all his anger at the bottom of the pool. He and Mateo hold hands as they swim to the surface, and Rufus insists they need to go to a nightclub for Deckers.
Meanwhile, a cop named Officer Andrade lets Malcolm and Tagoe out of jail because he understands what it’s like to lose a loved one. Malcolm and Tagoe call Rufus and agree to meet at Clint’s Graveyard, the Decker club. When Rufus posts a picture of the sign on Instagram, Peck and his gang head there to enact their revenge. In the club, Mateo wishes he’d spent more time here. He and Rufus sing karaoke to “American Pie” and afterwards, Mateo kisses Rufus—he feels that Rufus brought him to life. Then, Malcolm, Tagoe, and Aimee arrive. Meanwhile, Sandy and Delilah interview Howie in a car—Howie is secretly on his way to visit his first love. He has lots of regrets about how he lived his life. Sandy’s questions are boring, so Delilah takes over. Howie answers truthfully that he wishes he’d been able to connect more with his family, and he realizes that while he’s never lonely thanks to all his fans online, he craves real intimacy. He dies when the car swerves and hits a wall to avoid Peck, Damien, and Kendrick. Delilah and Sandy survive.
Rufus hugs his friends and introduces them to Mateo and Lidia. Then, everyone gets on the dance floor. Mateo and Rufus slow dance and lament everything they’ll never get to do. Mateo takes Lidia aside and apologizes for not coming out to her sooner. She asks what she’s going to do without him, a question that Mateo can’t answer. Mateo turns his attention back to Rufus when he sees that Peck and his gang have arrived with a gun. Mateo punches Peck, which gives Malcolm the chance to body-slam the rest of the gang. Rufus gets ahold of the gun, shoots it into the wall, and runs away with Mateo. Unbeknownst to them, they run past Dalma Young, the developer of the Last Friend app. Though Dalma hates how some people abuse the app, she believes that Last Friend does great things. Mateo asks Rufus if they can go to his apartment and then to visit Dad one last time, and Rufus agrees. In Mateo’s room, Rufus takes pictures of Mateo jumping on his bed, and then Mateo sits down to sing and play Elton John’s “Your Song” for Rufus. Rufus takes a video. The boys eat, lie down, and say they love each other. They promise to not get out of bed—but Mateo gets out of bed an hour later to make tea. The broken stove ignites and kills him.
Rufus is overcome by grief and anger. He rides with Mateo’s body to the hospital and then visits Dad. He calls Lidia, who promises him that she’ll fulfill Mateo’s wish to tell Dad he was gay if Rufus doesn’t get the chance. After this, Rufus is able to leave Dad a note introducing himself and letting him know that Mateo was brave on his End Day. He also leaves his Instagram username. Then, Rufus heads for Althea Park. Delilah is at a diner by Althea Park writing Howie’s obituary when she decides she has to call Victor and know for sure if her call was a bad joke. It’s not. Victor gets in his car and speeds for Delilah. Rufus watches the video of Mateo singing to him over and over, and then he crosses the street without looking.