The movie starts out with Frank Herlihy (Greg Kinnear) walking down a Manhattan street, talking to his wife. We only hear his side of the story, but he is calming her down, saying that the person who called her about the apartment he is supposedly renting must have had the wrong number. When she tells him the person had Frank's business card, he quickly recovers and says that it was supposed to be a surprise for her. She is convinced, and they hang up. He quickly calls the real estate agent and chews him out for calling his wife, because he said for the agent to call "Amber...does that sound like the name of a woman a guy my age would be married to?"
As he is talking to the real estate agent, we see two people in their apartment getting ready to set up an air conditioning unit in their window. The woman says she wishes they had hired someone, but the man reassures her that he knows what he's doing. As they set it up, Frank stops underneath their window, still talking on his phone. They set up the air conditioner and step back, praising their work. Suddenly, the unit falls backwards out of the window. In slow motion, Frank jumps back, barely missing getting smashed by the air conditioner. He says to the person on the other end of the phone, "You'll never believe what almost just happened-" when WHAM! A bus hits him. His suit jacket goes flying up into the air, and he comes back into the picture. As people go running towards the accident, two people run right through him. (After they walk through him, they both sneeze, which becomes a running gag throughout the film). Frank complains that this is a really inconvenient time for him to die.
Next we see a whole montage of cringe-inducing medical equipment, before we meet Bertram Pincus (Ricky Gervais), a dentist, hastily shoving cotton into a chatty patient's mouth. After this appointment, his coworker, Dr. Prashar (Aasif Mandvi) asks him if he needs to use the x-ray machine, since he needs to use it for the rest of the day. Bertram says he doesn't, as he's cleared his schedule for the day. Prashar assumes he's taken a personal day for a date or something along those lines, but Bertram refuses to share any details. Prashar invites him to the office party to celebrate the new baby he and his wife have just had, but Bertram sneaks out during the party, which Prashar notices. Bertram also avoids a Greenpeace man outside his office, and refuses to talk to or even look at anyone.
When Bertram arrives home, he is in the elevator when Gwen (Tea Leoni) comes into the building behind him, carrying a bunch of bags and boxes. She asks him to hold the elevator, which he pretends to be doing as he jams the "Door Close" button. When he is in the safety of his own apartment, he sits in front of three large bottles of (I don't know, whatever you have to drink to clean your system before a colonoscopy?) which he drinks, gagging frequently (another running gag, no pun intended, throughout the film). He runs into the bathroom shortly after.
Bertram goes to the hospital the next day and has a very funny encounter with the receptionist filling out his form. He refuses to answer many of the questions like marital status, occupation, any food allergies ('I don't plan on eating here"), etc, saying they're unnecessary. Finally, he gets onto the hospital bed in preparation for his colonoscopy. The surgeon (Kristen Wiig from SNL) and the nurse talk at length about Wiig's new spray-on tan, before Bertram gets frustrated and asks if they could please talk about his bowels instead. Wiig says she doesn't recommend his request for a general anesthetic, as it's a simple colonoscopy, but he is very set on not being awake for the procedure.
The next morning, when Bertram is discharged, he walks out of the hospital and snarls at the group of nurses smoking outside. He says to one nurse, who isn't smoking, just lounging against the wall, that they're making a great impression for healthcare. The nurse (who is dressed in very old-fashioned scrubs) looks at him, astonished, wondering if he's talking to her. He is dismayed that the one person he talked to turns out to be a lunatic, and as he's walking away, she follows him. Along the way, she talks to other people, saying this man "can see us!" Eventually, Bertram has a whole group of people running after him in various costumes. He hides and gets away, but when he gets back to his apartment, finally realizes something is up when one man (Alan Ruck) walks towards him and just glides through the oncoming street sweeper instead of getting hit.
Bertram makes his way back to the hospital, demanding from the surgeon to know if anything unusual happened during his procedure. After a lot of roundabout talking, she and a hospital lawyer (Michael-Leon Wooley) tell him that technically, he died for 7 minutes due to a complication with the general anesthetic. Unfortunately, he can't sue them because he signed a release form in his drug-addled post-op state.
Back at his apartment, he walks through Frank, and tries to find a way to escape. Gwen is outside, hailing a cab in the rain, and Bertram jumps in her cab. Unfortunately, Frank is already sitting beside him. Bertram then goes to a bar, where Frank follows him. After an argument about the drinks Bertram tries to order, he eventually orders the one Frank says is his favorite, a sapphire martini up with olives. Frank tells him his dilemma - he died 14 months ago and now his widow, Gwen from Bertram's building, is getting married to another guy, a jerk who is only after the money Frank left her in his will. Since Bertram is the only guy who has ever been able to see the hundreds of ghosts in New York City, they're all so excited and want him to finish their unfinished business that's keeping them from moving on completely. At this point, another ghost named Marjorie interrupts them, saying she wants him to go to his daughter and retrieve the letter she slipped under the carpet on accident, telling her all about how the feud with her sister is actually Marjorie's fault. Bertram refuses to help, and goes back to his apartment.
That night, while Bertram is in bed, he wakes up to find a ton of ghosts, including the naked ghost from the previews, in his room. He tries to escape through the elevator, but it too is crowded with ghosts clamoring for his help. Frank sarcastically says "Oh no, did I give all these ghosts your home address?" Bertram takes the stairs outside, where all the ghosts are already waiting for him. Frank says he's good at convincing people of things, and if Bertram helps Frank with Gwen, he will convince all the other ghosts to leave him alone. Bertram agrees.
The next day, Bertram goes to see Gwen's lecture. She is an archeologist at a local museum. Frank suggests planting a seed of doubt in Gwen's mind about marrying her fiancée, and wonders where they can find a hot male model to do the job. Bertram, staring at Gwen, says it might not need to be a model, just an average guy. Frank laughs and says Bertram can't seriously be talking about himself. Eventually, Bertram convinces Frank that he could be the guy to do the job, and Frank agrees they'll try it out. After the lecture, Bertram goes up to Gwen and says he owes her an apology. Gwen rips into him, asking if the apology is for not holding the elevator, or for stealing her cab, or for all the times she's said hello in the lobby of their building, and hasn't even been acknowledged in return. Awkwardly, Bertram starts making jokes about the mummy in her presentation, talking extensively about how he must not have had a good dentist, due to the tooth decay. She walks off.
The next day, Frank and Bertram are in the elevator of the apartment building, going to the lobby, when it opens on the floor below Bertram's to reveal Gwen waiting for the elevator. She stops short, saying she'll wait for the next one, but Bertram tells her to get in. He starts to speak multiple times, but Frank is shouting that he's not ready yet. Again, Bertram makes dental humor, still going on about the mummy. They exit at the lobby, and to everyone's surprise, Gwen turns around and asks if Bertram would come and take a look at the mummy for them, since they had never considered that an infection of the mouth might be why he died. In a funny scene, Bertram takes out his date planner and flips through, saying multiple days are not good for him. Finally, Frank yells at him to hurry up, since Gwen looks like she might just cancel, and Bertram says Thursday at 4.
Over the next couple of days, Frank is getting anxious. He yells at Bertram for coming home late one night, then sees that he has bought a new shirt for the meeting at the museum. The afternoon of the meeting, Bertram nervously prepares in the mirror, fixing his hair multiple times. At the museum, Bertram tells Gwen that the mummy's teeth are so horrible that it just may have been a dental infection that killed him. Gwen is in awe, and then offers to show Bertram the mummy's penis, which was apparently cut off and contained in a separate jar. During this exchange, Bertram makes Gwen laugh many times, and she sees that he still has the tag on his shirt, which makes her smile to herself at the obvious effort he put in for the day. She invites him to the gallery opening at the museum, but Bertram declines due to the enormous amounts of people that will be there.
They walk home together and stop on a bench as Gwen struggles to find her keys, since her keychain recently broke. She tells Bertram that her husband died a little over a year ago, and then asks him if she can ask him a potentially inappropriate question. Bertram looks hopeful, until she asks him to look at a tooth that's been bothering her. He does, but then is startled when a ghost, Irish Eddie, pops up behind them, berating him for not helping the other ghosts. Bertram finds it very difficult to not talk to the ghost and make himself look weird in front of Gwen, when Naked Guy shows up too. Gwen starts to leave, but her fiancée Richard (Billy Campbell) shows up, after Bertram mistakes him for another ghost. Richard invites Bertram over to dinner that night, which he accepts.
Frank shows up for the dinner, and tells Bertram to stop complimenting Richard on his cooking. Bertram manages to get some digs in, especially when Richard tells him about his work with poor prostitutes in foreign countries ("so are you still in the sex business, then?). Even with the inappropriate jokes, he is making Gwen laugh while Richard looks offended and stone-faced. Richard takes a phone call, and Bertram and Gwen have a conversation where he makes her laugh hysterically. Richard comes back and says he has to go into the office (he is a human rights lawyer, by the way). Gwen lets out her dog, a huge kind that I don't know the breed of, and Bertram's gag reflex goes off again because of the smell. They take the dog for a walk, where his bathroom duties make Bertram gag even more. We find out that Gwen discovered Frank's affair on the day he died, which Frank is heartbroken to find out she knew. We also find out that one of the reasons Bertram is so anti-people is because his heart was also broken. His old girlfriend, Sarah, went abroad for a year and promised to be faithful, but married someone else without even telling him. They go for a drink, where Bertram orders another sapphire martini up with olives. Gwen comments that this was Frank's favorite drink, to which Bertram replies, "Sorry, I forgot." She is taken aback, since she had never told him, but Bertram fumbles around and covers up his mistake.
Later, in Bertram's apartment, Frank is making more plans to sabotage Richard. Bertram asks Frank what he has against Richard, because he saw no signs that he was ever planning to steal Gwen's money. Frank comes up with very flimsy excuses, and Bertram realizes that there was never actually anything wrong with Richard - Frank just didn't want Gwen to marry someone else. Bertram says he can't morally break up a happy relationship with a decent man that Gwen loves, even though Frank realizes that Bertram is falling in love with Gwen as well.
The next day, Frank catches up to Bertram on the street. Bertram is smiling and carrying a Bulgari bag. He informs Frank that Gwen was offered a job in Egypt for 6 months, and that this broke up her and Richard. Now he is planning on making his move. He meets up with Gwen and gives her the bag, which turns out to be a keychain to replace the one she broke. She is astonished he remembered, and even more so when he flat-out tells her the amount of money he spent on it. He says it's not like it's Peruvian gold, which Frank told him was her favorite jewelry. She looks at him sideways, using a look Frank described as her "pirate look." Bertram tells her to stop using the pirate look, to which Gwen finally freaks out. She demands to know how he knew this phrase, how he knew she loved Peruvian gold, and how he knew Frank's favorite drink was a sapphire martini up with olives. Bertram tries to lie, but eventually tells her that during his colonoscopy, he died, and now he can see dead people, including Frank. She is furious at what she thinks is an extraordinary attempt to weasel his way into her life, and says she was so sure she had been wrong about him being a jerk, but now that's what she thinks again. Bertram swears he is telling the truth, and tells her to ask him anything, something no one could possibly know but Frank, since Frank is also there with them. She gives in, saying Frank used to have a recurring nightmare that made him wake up in tears, and he never told anyone but her. Frank says he used to dream about drowning, about seeing the surface of the water but never being able to reach it. Bertram tells Gwen this, and she says that isn't even close to the dream Frank had. As she walks away, Bertram tells her he loves her, but Gwen says not to call her. Bertram demands to know why Frank lied, and Frank says that Bertram is a horrible man, who doesn't care about anyone but himself, and Gwen already had someone like that.
At the dentist's office the next day, Bertram goes up to Prashar and spills all about how he was in love with Gwen. Prashar is astonished that Bertram is opening up to him, and shows him a poster above his work station, saying something along the lines of "A life not lived for others is a life not worth living." Bertram appreciates this. Later, he is working on the same patient from earlier, who both times has talked obsessively about her 5-year-old son, Alex, and shoves a mold into her mouth to shut her up. He goes out into the lobby while the mold is hardening, and finds it full of ghosts. He tries to run away, and comes back into the office in a roundabout way. When he gets back into his room, the mold is so hard on the woman's teeth that it practically rips them out.
After the woman is gone, he goes back into the lobby, where all the ghosts are waiting. There is a montage of him taking care of all their unfinished business, when a light shines on all of them and lets them move on. It is revealed that the man who went through the street sweeper in the beginning was married to the talkative woman at Bertram's office, and he helps her son recover a stuffed animal he lost on the day his father died, making him think the animal was actually his father.
Frank is standing outside Gwen's apartment, when she comes out, all dressed up, and checks her reflection in the mirror. Her face crumples for a split second, and then she gets into the elevator and leaves.
Straight from the office, Bertram goes to the museum and begs Gwen to listen to him. She says she has to leave to start packing for Egypt, and Bertram runs after him. Suddenly, outside the museum, Bertram is HIT BY A BUS. His jacket flies up into the air, and he appears next to Frank. His body is lying on the ground, when Richard comes along and starts giving him CPR. Frank apologizes to Bertram for lying about his dream, and tells him (without us hearing) the real one, just in case Richard is able to revive Bertram. As he does this, he says to Bertram that the tears Gwen are crying are real, and they're for Bertram. Just after he says this, a light shines brightly, and Frank says his ride must be here.
Bertram wakes up in the hospital, where the same surgeon is there to greet him. He comments that she must have gotten another spray-on tan, and that it makes her eyes pop, just like she said she wanted in the beginning. She says Gwen was there to visit, but they have a strict family-only policy.
Some time later, Bertram is back at work when Gwen comes in, saying she made an appointment with Prashar since she didn't think Bertram would be working so soon. He tells her, just as he's about to leave, that Frank's real dream was of being 8 years old, walking through a giant forest with his father at his side. Suddenly, his father lets go of his hand, and Frank can't find his way out of the forest. Teary-eyed, Gwen agrees that this was the real dream. She starts to walk away, but comes back and says it hurts when she smiles. Bertram says he can fix that.
You can send in your spoiler to other movies by going here.