If Ricky Gervais’ characters have a redeeming quality, it’s their vulnerability. In the British version of The Office, Gervais’ David Brent was a blowhard who deluded himself into thinking he was a popular and inspirational boss (“It’s like bloody Dead Poets Society out there!”), when in reality his petty backbiting, clueless bigotry, excessive braggadocio, and general narcissism were objects of scorn and indifference. Yet I never hated David Brent: he’s a pitiful, emotionally needy figure, and that tempered his egoism.

Ricky Gervais understands comedy. As Brent, he demonstrated how the slightest misjudgments in tone and context ruined the wannabe comedian’s attempts at levity. Perhaps the most brilliant moment in The Office was one of its most subtle: Brent smiles weakly and his eyes dart from side to side as he explains his motto, “Live hard—live too bloody hard, sometimes.” Gervais’ glance suggests a man desperately trying to convince himself of his own bullshit.

In Ghost Town, Gervais plays Dr. Bertram Pincus, a Manhattan dentist who is such a misanthropic prick, he might make David Brent pause for reflection. Placing support instruments in his patients’ mouths just to shut them up, he sneaks out of the office early to avoid looking at a co-worker’s baby pictures. Retreating nightly to his antiseptic apartment, the dentist lives a lonely, hermetic existence. “It’s not crowds I dislike,” he says. “It’s the individuals in the crowds.”

After a botched anesthetic during his colonoscopy leaves him clinically dead for seven minutes, Pincus gains the ability to see and speak to the ghosts who haunt New York, stranded in a purgatorial state until their “unfinished business” is attended to. The most persistent of these lost souls is Frank (Greg Kinnear), a smarmy, unfaithful husband who wants Pincus to break up his wife’s (Tea Leoni) impending marriage with a “sleazeball lawyer.” Pincus agrees on the condition that he will be left alone.

Gervais’ comic genius is not entirely intellectual. Like W.C. Fields and the Three Stooges, he simply looks funny. His 47-year-old frame is short and plum-shaped, with swollen cheeks, a neck that sags tiredly, and a mouth poised in a weary grimace. Preparing to meet Leoni, he experiments with a look in front of a mirror. The juxtaposition between Gervais’ puffy face and his bizarre aesthetic choices (shirt buttons undone; hair combed like a bad ‘80s rock star) is poignant. It’s heartbreaking to watch Gervais’ characters try to be more dashing and charismatic than they are.

The film is directed and co-written by David Koepp, whose recent screenplay credits, including War of the Worlds and Indiana Jones and the Kingdom of the Crystal Skull, don’t indicate how good he is with funny, rapid-fire dialogue. It’s nice to see a mainstream romantic comedy with so many intelligent and entertaining conversations. The other performances are all effective, particularly Greg Kinnear, who captures a certain kind of amicable smugness.

A few weeks ago, I saw a screening of the upcoming How to Lose Friends & Alienate People, a truly awful comedy starring Simon Pegg as yet another jerk that finds redemption. The filmmakers expect us to sympathize with its obnoxious hero, despite the fact that his character arc involves no real change in personality. He’s a prick from the first scene to the last. Maybe Gervais’ secret is that he always depicts his characters with blunt objectivity. The actor doesn’t expect us to sympathize with Pincus, he earns his redemption in a way that is plausible within the story’s context.

While Gervais was not involved in the scripting or directing of Ghost Town, it still feels tailor-made for his talents. Pincus is the type of sad-sack that Gervais specializes in, and there are cringe-inducing scenes that showcase his mastery of embarrassment comedy. Initially, I was worried that Gervais would be straitjacketed by the conventions of a Hollywood romantic comedy, but Ghost Town understands the persona. It’s a Ricky Gervais vehicle, through and through.