SPOILER ALERT: Do not read if you have not yet watched “After Life,” streaming on Netflix.

In “After Life,” Ricky Gervais plays a middle-aged man who dispenses withering one-liners and verbal abuse at pretty much anyone who crosses his path.

On the surface, the role may not seem like a stretch for the infamously mean comedian. However, the takeaway from the darkly comic Netflix show, which is entirely written and directed by Gervais, may surprise a few people.

“My character is like a superhero in a way: he discovers he has this power, which we’ve all got, to say what you want. It goes well, it’s exciting, but then with great power comes great responsibility, and he’s got to learn who deserves it and who doesn’t,” Gervais says. “He goes too far, absolute power corrupts absolutely, and he realizes he’s turning into a maniac.”

“After Life” centers around Gervais’ character of Tony, a middle-aged journalist whose “perfect life” has been reduced to dust since his wife, Lisa (Kerry Godliman), died of cancer. Tony sees no reason to stay in this world and so, in the words of Gervais, decides to “turn himself into a psychopath so he doesn’t feel pain anymore.”

The series’ grounded, simple setting should be familiar to fans of “The Office” and “Extras,” but the quirky fun of Gervais’ previous shows is replaced with a darker, nihilistic humor.

At his lowest point, Tony sits sobbing in the bath, a razor in his hand, on the verge of committing suicide. The only thing that stops him ending it all is his dog, who comes pining for food at that exact moment.

“This isn’t just a knock about comedy imagining a man without inhibitions,” Gervais says. “He’s really deeply in pain, this is a wounded animal. He gets drunk every night, he tries heroin, he tries being nasty, he tries therapy, but he just wants to feel better.”

Despite appearances and obvious similarities, Gervais says he and Tony differ in one key respect.

“He’s the most like me in my head, but I’m not as brave as him, I still worry about consequences,” Gervais explains.

In one scene, Tony sits in a café with his young nephew and tries to order from the kids’ menu, only to be told that the kids’ menu is only for kids by a stubborn waitress. Tony wins the argument by insisting his nephew will have two portions, flashing a victorious smirk at the waitress as he tucks in.

Gervais says the same thing happened to him in real life, only instead of standing up to the waitress, he meekly backed down and ordered from the grown-ups’ menu.

“I wish I could have done what he had, and particularly now,” Gervais quips. “I can’t send a soup back if there’s a dead rat in it because of the way you’ll all film me and put me on YouTube. People would say, ‘Oooh who does he think he is, Tom Cruise?’”

Gervais admits it might be hard for the audience to relate to a character who appears to be so terrible, were it not for the recording Lisa left Tony before she died and the home videos of their time together. The videos show Tony used to be “a nice bloke” who liked to prank Lisa and cackled with unbridled joy at her loving reactions.

As well as an exploration of grief, Gervais uses “After Life” as a platform for his implicit commentary on comedians and the growing trend of audience members calling them out.

In a telling sequence, Matt, Tony’s brother-in-law played by Tom Basden, convinces him to join the rest of the newspaper staff at a local comedy gig. While everyone else is laughing, Tony sits in the front row, his face a picture of annoyance that turns to pain when the comedian tells a joke about suicide. Afterwards, Matt and Tony argue about his right to be offended by the joke.

“He’s just trying to make people laugh,” Matt says.

“Matt in that situation is what I think in real life. When a comedian tells a joke about something that affects you, he doesn’t know that, he doesn’t mean you. It’s a nebulous concept, you have to jump in the way of the bullet to take it personally,” Gervais explains. “People today ask, ‘Why are you having a go at me?’ But we’re never having a go at you unless we name you — unless we say, Derek Spew at 13 Acacia Road, you’re an absolutely twat. It’s not about you, it’s a joke.”

The finale of the six-episode series features a playful running gag about Kevin Hart, which ends in Tony offering a colleague at the Tambury Gazette a snow globe with Hart’s face in it. While Gervais says he wrote the show well before Hart’s old homophobic tweets resurfaced and the Oscars hosting debacle ensued, he believes the comedian’s social media skewering sets a dangerous precedent.

“I think it’s ridiculous that people now are looking back at historic tweets. Just because they’ve seen it for the first time they want someone punished and they want them to apologize for something they did 10 years ago,” Gervais says. “Kevin Hart is one thing, but he apologized. Does he have to apologize every day, every time someone brings it up? If you keep punishing someone for something they don’t do anymore, it’s like you’re saying there’s no value in being better.”

Although this year’s hostless Oscars seemed to go down well with most in Hollywood, Gervais thinks the Academy is still missing a trick in “taking themselves too seriously” and not hiring a host who can “properly take the mickey.”

“We shouldn’t expect it to be like the Nobel Prize,” Gervais laughs. “It’s the Oscars of entertainment, why do we think people who make films are above it all?”

While at times “After Life” strays into discussions of the role of comedy in society and the existence of God, two of Gervais’ favorite talking points, the deeper message of the show is conveyed through the smattering of quirkily memorable secondary characters, another of the comedian’s signatures.

Tony is at first frosty towards an old lady (“Downton Abbey” star Penelope Wilton) who sits on a graveyard bench chatting away to her husband’s tombstone, and downright offensive to a local weirdo (David Earl) who will resort to anything to be featured in the Tambury Gazette, but Gervais explains that each of the minor characters help him come to terms with losing his soulmate.

By the end of the show, his outlook on life has changed.

“The thing with grief is that people start getting fed up with you. You can be having a really hard time, but let’s be honest, after a year, people behind your back are going, ‘F—ing hell, c’mon, it’s been a year,” Gervais says. “At the end of the day, it’s all those little mundane interactions that actually save your life — they’re the variety of life, they stop you from feeling too sorry for yourself. He’s got to take the dog for a walk, he’s got to go to work to make money to get drunk, and after all that, time heals.”

“After Life” is streaming now on Netflix.