While vacationing in Switzerland, physician Chris Nielsen (Robin Williams) meets artist Annie Collins (Annabella Sciorra). They are instantly attracted to each other, and bond as if they had known each other for a long time. They marry and have two children: Ian (Josh Paddock) and Marie (Jessica Brooks Grant). Their idyllic life comes to an end when the children die in a car crash. Life becomes very difficult: Annie suffers a mental breakdown, and the strains on their marriage threaten to lead to divorce, but they manage to struggle through their losses.
On the anniversary of the day they decided not to divorce, Chris is killed in a car accident. Unaware that he is dead and confused when nobody can interact with him, Chris lingers on Earth. He watches Annie's attempts to cope with the loss and he attempts to communicate with her, despite advice from a spirit-like presence that it will only cause her pain. When his attempts only leave her more distraught, he decides to move on.
Chris awakens in Heaven, and finds that his immediate surroundings are controlled by his imagination. He meets a man (Cuba Gooding Jr.) whom Chris seems to recognize as Albert, his friend and mentor from his medical residency, and the spirit-like presence from his time as a "ghost" on Earth. Albert will be his guide in this new life. Albert teaches Chris about his new existence in Heaven, and how to shape his little corner of it and to travel to others' "dreams". They are surprised when a Blue Jacaranda tree appears unbidden in Chris' surroundings, matching a tree in a new painting by Annie, which was inspired by Annie's belief that she can communicate with Chris in the afterlife. Albert explains to Chris that this is a sign that the couple are truly soul mates. However, Annie is overcome with despair and decides that Chris cannot, in fact, "see" the painting and destroys the piece. Chris sees his version of the tree disintegrate before his eyes which coincides with the painting being destroyed in the real world.
Chris laments he will not see his wife and encounters an Asian woman with the name tag "Leona", whom he comes to recognize as his daughter Marie, living in an area shaped like a diorama she loved in life. The two share a tearful reunion.
Meanwhile on Earth, Annie is unable to cope with the loss of her husband. She then decides to commit suicide. Chris, who is initially relieved that her suffering is over, quickly becomes angry when he learns that those who commit suicide are sent to Hell; this is not the result of any judgment made against them, but that it is their nature to create "nightmare" afterlife worlds based on their pain. Chris is adamant that he will rescue Annie from Hell, despite Albert's insistence that no one has ever succeeded in doing so. Albert agrees to find Chris a "tracker" (who takes the form of Sigmund Freud) to help find Annie's soul.
On the journey to Hell, Chris finds himself recalling his son, Ian. Remembering how he'd called him the one man he'd want at his side to brave Hell, Chris realizes Albert is Ian. Ian explains that he chose Albert's appearance because he knew that Chris would listen to Albert without reservation. Before they part ways, Ian begs Chris to remember how he saved his marriage following Ian and Marie's deaths. Chris then journeys onward with the tracker.
After traversing a field containing the faces of the damned, they come to a dark and twisted replica of Chris and Annie's house. The tracker then reveals himself as the real Albert, and warns Chris that if he stays with Annie for more than a few minutes he may become permanently trapped in Hell. All that Chris can reasonably expect is a chance to say a final farewell to Annie.
Chris enters the house to find Annie suffering from amnesia, unable even to remember her suicide and tortured by her decrepit surroundings. Unable to stir her memories, he "gives up", but not the way the Tracker hoped he would; he chooses to join Annie forever in Hell. As he announces his intent to stay to Annie, his words parallel something he had said to her when he left her in an institution following their children's deaths, and she regains her memories even as Chris is succumbing to her nightmare. Annie, wanting nothing more at that moment than to save Chris, ascends to Heaven, bringing Chris with her.
Chris and Annie are reunited with their children in Heaven, whose original appearances are restored. Chris proposes reincarnation, so that he and Annie can experience life together all over again. The film ends with Chris and Annie meeting again as young children in a situation roughly parallel to their first meeting.