In May 2004, the actor Lisa Kudrow met her colleague Michael Patrick King for lunch in Los Angeles. Kudrow had just finished playing the part of Phoebe Buffay in Friends, and King had ended his run as director, writer and executive producer for Sex and the City. They had known each other for years and now they were considering working together. It should have been a match made in TV heaven but Kudrow brought a little bit of TV hell along to that lunch date, too.

“He said: ‘I don’t imagine you want to do another show,’ and I said: ‘No,’” Kudrow recalls. “The only thing I would want to do was this … ” She then assumed the persona of a very different sort of performer: a jaded, craven, fading TV star, driven a little screwy by fame. “She’s really phoney,” Kudrow says. “She’s so desperate to be in the spotlight, and she’s missed it so much. She had this weird, continental-ish, theatre-y accent.”

Kudrow’s character was not a new creation. It pre-dated Friends, and was something she had come up with while training with the Groundlings improvisational comedy troupe in Los Angeles. “We would do these character monologues,” she says. “I had one called ‘Your favourite actress on a talkshow’ – I didn’t even give her a name.”

King loved the performance. “This character was so completely unaware of reality and, basically, her own ego,” he says. “I started laughing and we started talking.”

“Three hours later, we had a TV show,” says Kudrow.

King knew that it would be difficult to make a successful show about a TV star to whom viewers could still relate. However, there was another type of programme that had been picking up ratings. “It was the dawn of reality TV and, in the writers’ rooms, people were freaking out,” he says.

“I remember season one or two of [US reality show] The Amazing Race,” says Kudrow. “I saw a married couple given a challenge where she had to eat such spicy food that she could barely swallow. She was vomiting and crying while her husband was screaming at her: ‘Finish it!’ I thought: ‘That’s the most humiliating thing I’ve ever seen.’ And it was on national television.”

Together they came up with an equally humiliating formula, pairing Lisa’s blowsy old actor persona with this violent new format to create The Comeback, perhaps the best comedy about television in the 21st century. The first season, which aired on HBO in 2005, followed the tribulations of Valerie Cherish (Kudrow), a hapless LA actor who, having starred in a sitcom during the late-80s and early-90s, tries to find fame again, not only by signing up to play the part of a cranky old aunt in a second-rate teen sitcom, but also by agreeing to a reality show documenting her attempt to make it back on to the small screen.

The series is presented as found footage from that reality show. “The Office came first,” Kudrow admits. “I was a fan; it definitely informed it.”

Despite its loose, apparently improvised feel, this new show was actually heavily scripted by Kudrow and King. “We wrote it out, right down to the ‘Ah, ah, ah’ pauses in speech,” he says.

Those lines were quite unlike anything Kudrow had performed on Friends. “Friends was joke-driven,” she says. “This didn’t have that; it didn’t have to be hilarious every second.”

Indeed, The Comeback’s own fake sitcom, Room and Bored, enabled the show to satirise the crummy comedies that were once the mainstay of American broadcast TV. King says there was one show from the early-90s that he had in mind. “It was called Down the Shore,” he says. “It wasn’t so much the quality of the writing, which was fine, it was that they were trying to pretend they were on the ocean, with the ocean in the background as a drop; that felt so fake to me.”

Lisa Kudrow with Robert Michael Morris in The Comeback. Photograph: HBO

Kudrow feels the parody was much broader and, at the same time, more acute. “There were so many of those comedies that had two-dimensional characters and weren’t that funny,” she says. “Sometimes the writers just seemed to hate the audience. I remember saying to writers, on earlier shows – not Friends – ‘Wouldn’t it be better, if this happened or that happened’, and they’d be like: ‘No that doesn’t matter. The audience is just stupid. I thought: ‘No, that’s not right.’”

The true villain of The Comeback is Room and Bored’s writer Paulie G (played by Lance Barber), a bro’-ish bully who delights in ridiculing Valerie. Watching the show today, it is hard not to see his treatment of Kudrow’s character as a wider comment on media misogyny, but she is reluctant to accept that label. “We didn’t call it that,” she says, “that was just the truth, the reality; that’s just the way it is.”

“TV writers perceived any woman over 40 as not fuckable,” says King. “It’s in the DNA of many, many writers’ rooms. The show is the closest thing to my experience in writing rooms, with male energy and the sophomoric madness that happens when people are trapped, trying to do a series.” Much of the first season’s spark lay in the way Valerie’s old-school brassy resilience was worn thin by Paulie G’s coarser approach. In fact, Kudrow believes the uneasy reception the show met when it was first aired came from the discomfort male viewers experienced watching so raw a depiction of male-on-female cruelty.

“The feedback from that first season was that it was really hard to watch,” says Kudrow. “I think for men especially it was really uncomfortable. I was aware that it was mainly straight, white guys who couldn’t watch it.”

King also thinks that Valerie was a challenge for audiences but the reason was because she was too nuanced. “Most comedy is built on archetypes,” he says, “and in most TV comedies, the female archetypes were very, very limited. There was the sexy young one that everyone wanted to have sex with, and then there was the kooky, older one, who was over the hill. You weren’t both.”

Despite respectable viewing figures – “It was getting about the same as Entourage got in their first year,” says Kudrow – the show was cancelled. And then something quite odd happened: after it came off the air, viewers and critics alike began to reassess The Comeback. “They actually published revised reviews,” she says. “That was rare; it was crazy rare!”

In 2014, 10 years after that first lunch date, when reality shows had all but conquered daytime TV and The Comeback’s reputation had been restored, a second season aired, with Valerie cast in another fictional production – Seeing Red, an HBO dramatisation of her tortuous experience filming Room and Bored – and again simultaneously working on a reality production.

“When we did the second season, we addressed HBO and streaming services and where Valerie had gone,” says King. “She was angry, an alcoholic and she didn’t have to smile. She was dark, and the joke was for us: Valerie was being forced to be dark when all she wanted to be was light and loved. She was being hated; she became a success. That’s where television is now.”

Despite this darkness, the second series may actually make for easier viewing; it certainly met with greater conventional success. It was, King admits, as if the world had caught up with Valerie and her hapless ambitions. “Valerie is my cautionary tale of choosing fame over family,” says King. “It’s just one of my scariest thoughts, that someone would choose this illusive thing over the real people in their lives.”

Unfortunately, the death of one of those very real people in King and Kudrow’s life may mean we won’t see a third series of The Comeback. The actor and dramatist Robert Michael Morris had been King’s theatre teacher at college, before becoming a professional actor later in life. Morris had retired by the time The Comeback was casting, but King more or less wrote the part of Mickey, Valerie’s hairdresser and best friend, for him, and convinced Morris to come out of retirement to perform on the show. Despite a spell of ill health, Morris reprised the role in the second season, but died in the spring of 2017. Kudrow says she really cannot see how she could make another series. “There’s nothing funny about that, and you have to address it,” she sighs. So is his passing preventing her from considering another series? “It is right now,” she says.

King, despite having known Morris for longer, is a little more sanguine. “Television is always evolving,” he says. “We can always put Valerie’s head in the window and then slam it.”