What’s so funny about divorce?

Not much, you might say, but HBO is hoping to mine heartbreak for laughs with its new series, the bluntly titled “Divorce.”

In her first lead series role since “Sex and the City” ended 12 years ago, Sarah Jessica Parker stars as Frances, an executive recruiter who lives in a picturesque Westchester County home with her house-flipping husband, Robert (Thomas Haden Church), and their two children.

Their relationship is drifting along in a state of resentful inertia when a dramatic incident at a friend’s birthday party spurs Frances to ask for a divorce. Not coincidentally, she’s also having an affair, but as we soon discover, there are more fundamental problems in the marriage.

Numerous films, including “Kramer vs. Kramer” and “Scenes From a Marriage,” have explored the subject, while marital strife and infidelity in particular are practically required of TV dramas aspiring to the “prestige” label. But making a half-hour comedy charting a breakup over potentially many seasons represents a number of unique creative challenges – not the least of which is how to find the humor in subjects as grim as alimony and custody disputes.

“I was really curious about exploring marriage and everything that meant,” says Parker, who is also an executive producer on the series and began developing the idea that would become “Divorce” via her production company, Pretty Matches. “I realized that I hadn’t really seen that idea illustrated in television in a long time. It was just a landscape that I thought seemed rich.”

Created by Sharon Horgan, the Irish writer and star of the Emmy-nominated Amazon comedy “Castastrophe,” “Divorce, which premieres Oct. 9,” shares with that series an unflinching view of long-term commitment and a propensity for graphic sex-related humor. Paul Simms, a former writer-producer on “Girls,” serves as showrunner, lending it the pedigree of an HBO not-quite-comedy.

Parker was influenced by “An Unmarried Woman,” Paul Mazursky’s groundbreaking 1978 film about a woman’s rebirth after the end of her marriage. “I remember going to see its opening weekend with my parents, strangely enough; it’s what we did. I probably watch that movie every few years, easily. There was a time when we talked about normal lives and we found all sorts of virtue in those stories.”

In early 2014, HBO introduced Parker and Horgan, who had not yet broken through in the U.S. with “Catastrophe” but had earned a cult following in Britain as the writer and star of “Pulling,” a pitch-black BBC Three comedy about three single London women that was the downscale antithesis of “Sex and the City’s” frothy fairy tale.

Parker liked that there was “seriousness and sadness but also humor” to Horgan’s writing and thought it would suit the very particular tone of the series she envisioned. “I was looking for something that was neither fish nor fowl, that sat in a world between comedy and drama. I knew that divorce, on the surface, one doesn’t think of it as something funny, but it was incumbent upon us to find the humor.”

After Horgan wrote the pilot, Simms, who created the Phil Hartman sitcom “NewsRadio” and has a working relationship with HBO dating to “The Larry Sanders Show,” was brought on as showrunner. He believes the themes of “Divorce” will resonate widely. “The show is about a divorce, but it’s also so much about a marriage. Anyone who’s been in a relationship knows there are times in love when you hate the other person. But it passes.”

When it came to casting the role of Robert, Church – an Oscar nominee for 2004’s “Sideways” – was Parker’s first choice. The two had worked together on the 2008 film “Smart People.” “He is a supremely gifted comedian but is also beautifully able to portray a sort of quiet sadness,” Parker notes. “His skills are really special, and I knew he could inhabit Robert and illustrate Robert’s humor, his deep sense of disappointment, failure and his commitment to love.”

Church, who hadn’t taken a regular TV role since the late ’90s, was drawn to the “singularly collaborative” nature of the project. Though Parker is an executive producer, she and Church are very much co-leads, and within the series Robert’s perspective is given as much weight as Frances’. As a result, viewers may find their loyalties shifting back and forth – and back again – throughout the season.

“There’s not one criminal in the breakdown of the marriage,” says Church. “In the infamous words of Jim Morrison, nobody gets out alive.”

With his wry demeanor, Church also brings the series a level of baked-in humor, as do ensemble players like Molly Shannon, who plays Frances’ wealthy, childless friend Diane, and Jemaine Clement of “Flight of the Conchords” as Julian, the smug, granola-making professor Frances has been sleeping with on the side.

‘GOOD LAUGH RATIO’

Casting was key in achieving a “good laugh ratio,” says Horgan. “We didn’t have actors who could just deliver a funny line, they were actors you look at and you want to laugh.”

To keep the tone from becoming too caustic, the writers avoided going down “too many deliberately dark routes,” says Horgan, noting that Robert and Frances’ kids are not a huge factor in the initial story “because, you know, it’s hard to find comedy in kids getting (messed) up by their parents’ parting.” Horgan, Simms and company also worked hard to “find the light and ridiculous moments” in the story; there is, for instance, an ongoing subplot involving an enormous sheepdog inherited by Frances.

It also helps to have Parker, an actress who played one of the most beloved comedy heroines of all time, in a lead role, but “Sex and the City” fans should not tune in to “Divorce” expecting to see “Carrie Bradshaw, 10 years later,” says Simms.

Despite Carrie’s lingering imprint on the public imagination, Parker thinks that the differences between the characters are stark enough to ward off comparisons. “Basically every choice Frances made has been really, really different: her relationship with men, with children, with friendships, with the city that sits in the not too distant south, with money, privilege, access, sacrifice. It all feels so different for me as an actor.”

Still, there were some areas where Parker was determined to draw a clear distinction – particularly fashion. Unlike the label-obsessed Carrie, Frances dresses in a mostly vintage wardrobe, a look inspired by films of the ’70s, especially “An Unmarried Woman.” (The soundtrack is similarly full of tracks from the era.)

Early on, there were also concerns that portraying Frances in scenes with Diane and Dallas, a widowed friend played by Talia Balsam, might be too reminiscent of “Sex and the City.” But such reservations were soon dismissed as “ridiculous,” Horgan says, “because you’d never think that if it was three men together.”

A more reasonable question might be whether “Divorce,” a series about the demise of a single marriage, might last as long as one that chronicled the many relationships of four women.

“We are definitely not trying to do six seasons of two people fighting with each other,” says Simms, but at the same time, thanks to the proliferating divorce industry – the counselors, mediators and especially lawyers who “can inflame and extend things” – there’s no shortage of potential conflict to portray.

“I know people who are going into their fifth year or so of still-unresolved divorces,” he says. “You always hear those nightmare stories, where they end up where they would have ended up if they’d sat down with a legal pad at the kitchen table and said all right, you take this and I’ll take that.”

But that wouldn’t make for much of a show, would it?