For better or worse, HBO’s “Divorce” is the spiritual sequel to the network’s nearly 20-year-old “Sex and the City,” which followed the love lives of four single women in New York from gritty, contemporary intimacy to sentimental, friends-forever myth-making. Largely that’s because it’s hard to see Sarah Jessica Parker on an HBO half-hour without being reminded of her earlier, iconic role as Carrie Bradshaw, a single-and-looking sex columnist who follows her heart into and through the contradictions of modern relationships.

Parker is not, necessarily, a brilliant performer. But she brought an exceptional presence to Carrie, who should have been by all rights a thoroughly frustrating character. And indeed, she frequently was — but her irritating whimsy and ever-present optimism carried with it the character’s constant struggle to come to terms with how the world was not really made for her essential, undeniable femininity. Carrie was, in the opening credits of the show, a pink tutu amid a sea of suits. Something about her was bound to be crushed.

In “Divorce,” the actress plays Frances, a woman who has already been crushed. Eighteen years after Carrie’s breathless debut in “Sex and the City,” Frances is introduced to the viewer as a sullen, gimlet-eyed middle-aged woman, disenchanted and disengaged. As the title indicates, she’s on the verge of a life-altering event, but in the opening minutes, what’s remarkable about Parker’s performance is that she is presenting a portrait of endurance, a resolve to keep on keeping on.

“Divorce” was created by Sharon Horgan, writer and star of “Catastrophe,” who brings the same acerbic wit and tonal experimentation of that U.K. import to HBO’s decidedly non-British comedy about a couple trying to… uncouple. “Catastrophe” played with the growing pains of coming together, of trying to get serious after the honeymoon period has passed. “Divorce” is, in some ways, about how separation is easier declared than executed. The two shows each occupy a different part of the relationship life cycle, but the narrative is essentially the same: the messy, incomprehensible webbing of intimacy, and how it enmeshes or entraps us. “Divorce” has the added edge of ensuring, in its title, that at least in the traditional sense, this story doesn’t have a happy ending. The show is the darkest of comedies, funny in the way the twist of “Gone Girl” is funny — an examination of how marriage makes fools of all of us, when it doesn’t entirely estrange us from ourselves.

Where Frances is the show’s emotional center — an intentionally blank canvas — Robert (Thomas Haden Church) is the show’s delightful, off-color pigment. Robert has the demeanor of a military man without a war to fight, a Marlboro Man who’s run out of cigarettes. He has the bluster of a World War I veteran, delivering curt assessments that could be mistaken for declarations of war. But behind his red-cheeked machismo and surprising comfort with bodily waste, he is a man terrified that his justifiable anger is meaningless. One of the more astonishing successes of “Divorce” is how well Parker and Church sell Frances and Robert’s complex dynamic — as each drives the other first to unbelievable rage, and then later, to surprising generosity. Their viability as a couple changes with every passing minute, making their own will-they/won’t-they arc, such as it is, feel just as unknowable to the audience as it is to the characters themselves. It’s possible to see why they fell for each other, even as it’s easy to see why they might be better off splitting up.

Though the central relationship is captivating, “Divorce” makes missteps with its comedy. The subplot with married friends Diane (Molly Shannon) and Nick (Tracy Letts) seems injected into the series to add reliable punchlines, but feels overwrought, a literalization of the frustrations of marriage that seems out of place. And because the show takes place in a wealthy suburban enclave of New York City — Westchester County, since nothing as déclassé as New Jersey would do — “Divorce” carries with it a degree of tiresome upper-middle-class angst about how hard it is to have so many shiny things. And with the show’s title being a bit final, it remains to be seen how “Divorce” will find a way to continue its storytelling for multiple seasons, after the paperwork has been filed and the assets have been divided.

Unlike “Sex and the City,” “Divorce” is a slimmer and darker show. “Sex and the City” marked a moment of feminine power and found a way to reverse the conventional narrative of sexuality. “Divorce” is less obviously of its era, and is one of many series that has tried to illustrate the inner workings — or inner dysfunction — of a middle-aged marriage. But in its confused family life and uncomfortable intimacy, it is the perfect bookend to Carrie Bradshaw’s unfocused romanticism in “Sex and the City.” That was then; this is now.