Elizabeth Masterson (Reese Witherspoon), a young emergency medicine physician whose work is her whole life, is in a serious car accident while on her way to a blind date. Three months later, David Abbott (Mark Ruffalo), a landscape architect recovering from the sudden death of his wife, moves into the apartment that had been Elizabeth's, after 'discovering' it in what seems to be a 'fateful' happenstance.
Elizabeth's spirit begins to appear to David in the apartment. With ghostly properties and abilities it is clear something is not normal. She can suddenly appear and disappear, move through walls, and once takes over his actions. When they meet, they are both surprised, as Elizabeth is not aware yet of her recent history and refuses to believe she is dead. David tries to have her spirit exorcised from the apartment, to no success. Since David is the only one who can see and hear her, others believe that he is hallucinating and talking to himself.
David and Elizabeth's spirit begin to 'bond', as much as that is possible, and he takes her out-of-town to a beautiful landscaped garden he designed. Elizabeth tells him she senses she has 'been there' before, and, in fact, the garden was something she was dreaming of in the opening scenes of the film, wherein-after she was awakened by a colleague from cat-napping after working a 26 hour shift in the hospital.
Together, assisted by a psychic bookstore clerk, Darryl (Jon Heder), Elizabeth and David find out who she is, what happened to her, and why they are connected. She is not dead, but in a coma, her body being kept on life support at the hospital she used to work. When David discovers that in accordance with her living will, she will soon be allowed to die, he tries to prevent this by telling Elizabeth's sister, Abby, that he can see her and what the situation involves. It is revealed that one of Elizabeth's young nieces can also sense her presence.
Abby thinks David is mentally disturbed and drives him out of her house. Desperate, David decides to prevent Elizabeth's death by stealing her body from the hospital. He asks J.J, his friend, to help him and it is discovered that J.J is actually the former boyfriend of Abby, and he had set-up a blind date for David with Elizabeth, the night of the accident. The reason David can see Elizabeth is that they were meant to meet. He then admits to J.J and Elizabeth that he loves her and that is the reason he doesn't want her to die. He has 'gotten past' the death of his wife. While stealing Elizabeth's body, they are quickly discovered in the hospital. The security guards find them, pulling J.J away from Elizabeth's body, but when he is grabbed, her breathing tube is removed. David gets away from the guards a bit longer, but Elizabeth is now dying. David frantically kisses the dying Elizabeth, breathing some air into her lungs, while her spirit begins to fade away. Then, amazingly, her heartbeat returns and she miraculously awakens from the coma. However, the recovered Elizabeth doesn't remember anything that happened during the coma or any of the events with David, leaving him heartbroken.
Sometime later, Elizabeth goes back to her apartment. She is drawn up to roof of the building, which has been transformed into a beautiful landscaped garden. She finds David there, who has gotten in with a spare key Elizabeth's spirit had shown him. Just as he is about to leave, she asks for her key back. When their hands touch, her memory of the events during her coma are restored, and they kiss.