In the winter of 2013, Matt Teague [Casey Affleck] and Nicole Teague [Dakota Johnson] prepare to tell their daughters, Molly Teague [Isabella Kai] and Evie Teague [Violet McGraw], that Nicole's ovarian cancer is terminal. Outside, their best friend, Dane Faucheux [Jason Segel] keeps the children company.
In a flashback to 2000, Matt, a journalist, and Nicole, a theater performer, live in New Orleans. She introduces Matt to Dane, a friend from college working as a camera operator who dreams of becoming a stand-up comic. The three become close over the years. In 2008, Matt and Nicole reside in Fairhope with their daughters. Matt works as a war correspondent and spends months overseas, placing a strain on the family. Meanwhile, Dane remains in New Orleans working dead-end jobs. On Thanksgiving, Dane, unhappy with his life, decides to backpack at the Grand Canyon without telling anyone where he is going. A fellow backpacker recognizes his distress and offers support, and an unexpected voicemail from the Teague family renews his will to live. In 2010, Matt discovers that Nicole had an affair. With Dane's help, they reconcile their relationship. Dane returns home where he works as a manager at a sporting goods store and begins dating Kat [Marielle Scott].
In September 2012, Nicole receives her diagnosis and begins chemotherapy. Recognizing their need for help, Dane offers to stay with them for a few weeks. However, as Nicole's condition worsens, Dane decides to remain, taking on many household duties. Kat struggles to understand Dane's loyalty to the Teague family after weeks turn into months, and they break up. On Christmas, Nicole ruptures her abdomen, and Dane is left to watch over the girls. Following her surgery, the doctor reveals to Matt that Nicole's cancer has spread and gives her approximately six months to live. Nicole decides that she does not want to tell their daughters until her quality of life declines significantly.
Nicole prepares a bucket list which Matt and Dane help her accomplish; such as sitting as Grand Marshal of the Mardi Gras parade, swimming in a historic fountain with all of her friends, and writing letters to her daughters for future life events. As 2013 closes and Nicole becomes sicker, they decide to tell their daughters and Dane listens on in sorrow as the girls cry.
By the summer of 2014, Nicole becomes increasingly irritable, hallucinates, and experiences pain. Realizing that Matt is overwhelmed, Dane takes him hiking. Upon their return, Matt realizes that they are no longer equipped to care for Nicole, so he calls a hospice nurse, Faith Pruett [Cherry Jones]. Nicole's friends and family visit with her one last time. One night, Faith alerts them of Nicole's slowing heart rate, and they take her to the beach to watch one final sunrise. Returning home, Nicole dies with Matt and Dane at her side.
Following Nicole's funeral, Dane confines himself to his room and grieves alone. Matt writes an article called "The Friend," which he gives to Dane. Dane finally decides to go home after putting his life on hold to live with the Teague family for over fourteen months. Matt embraces Dane, expressing that simply saying "Thank you" isn't enough. In the epilogue, it is revealed that Matt's article won an award in Esquire magazine and that he and his daughters remain in Fairhope. Dane remains close to the Teague family and marries in 2019.