Gretchen (Aya Cash) and Jimmy (Chris Geere), so happy together. Photo: Byron Cohen/FXX

Hey dummies: Spoilers for You’re the Worst lie ahead, obviously.

It’s rare for a series finale to be satisfying. It’s even rarer for a finale to be perfectly in tune with the sensibility of the entire show, while also still offering the thrill of a pleasant surprise. You’re the Worst, one of the best if not the best of the anti-rom-com rom-coms in recent memory, managed to do all those things in Wednesday’s simultaneously cynical and sentimental send-off, “Pancakes.” Watching the FX series come to a close with such an on-point last episode was, appropriately, like watching two off-kilter weirdos who are perfect for each other finally fall into each other’s arms. Which is a pretty accurate description of what happens in between You’re the Worst’s main couple, Gretchen (Aya Cash) and Jimmy (Chris Geere).

The very first episode of season one put Gretchen and Jimmy in each other’s orbits by having them meet not-cute at the wedding of flaming idiot Vernon (Todd Robert Anderson) and the self-involved Becca (Janet Varney). So it’s appropriate that the last installment involves not one, but two weddings: the near-nuptials between Jimmy and Gretchen, and a deliberately vague flash-forward to another wedding day, which eventually reveals itself to be the remarriage of Lindsay (Kether Donohue) to Paul (Allan McLeod), the most boring, but also most moral, character on You’re the Worst. Paul is also the most forgiving; not many men would be willing to remarry a woman who, among other things, actually shanked them in the abdomen a couple of seasons ago. Ah, love.

The entire send-off season has been leading up to the big day for Gretchen and Jimmy, while throwing increasing hints — in addition to, you know, the anti-commitment messages the whole show has been throwing for five seasons — that there was no way the two of them would wind up together. In the previous episode, Edgar (Desmin Borges), Jimmy’s best man, longtime roommate, and favorite personal doormat, had told Jimmy point blank that marrying Gretchen would be a terrible mistake. Consequently, we spend much of the finale waiting for Jimmy to reach the same conclusion, or for Gretchen to ditch him, or something else catastrophic to slam the brakes on what would ordinarily be the happy ending in any other love story. Our instinct that everything will be derailed is only enhanced by what we see in that cryptic flash-forward timeline, which has been revealing over several episodes that Gretchen is hitting on other men at a hotel, that Jimmy is still in contact with that florist he hooked up with, and that there’s some anxiety on Jimmy’s part about seeing someone at the wedding he’s preparing to attend. We assume that someone is Gretchen. Until the big reveal that it isn’t — it’s Edgar, actually — because Jimmy and Gretchen are still together.

The present-day scenes and those glimpses of the future explain that Gretchen and Jimmy decide not to get married, but to continue being partners — to get up every day and choose each other, as Jimmy puts it — and that, at least as far as the series is able to show us, it works out. This story that began with two people swearing they would never commit to a traditional romantic relationship, ends with them both going back on that promise — they stay together, they start a family, they buy a new house — and also keeping it, because they opt to forego the formal “I do” part. It makes perfect sense for Gretchen and Jimmy, and for the show itself. In the end, You’re the Worst gets to eat its wedding cake and shit on it, too.

The ending also reinforces the notion that relationships can go in all sorts of directions that don’t jibe with the socially sanctioned ideas of what happy marriage looks like. In the finale’s closing montage, Lindsay and Paul, who often served as a guide to how not to do marriage, seem happy and secure tying the knot again. Becca and Vernon are, against all odds, still married and expecting a kid, but (shocker) Becca doesn’t look very happy, perhaps because Becca’s always going to be dissatisfied. Edgar is single and living in New York, developing that true-crime podcast he was listening to during Gretchen’s and Jimmy’s almost-wedding day as a TV series. (So, he quite literally carved out a future for himself by sitting in his car and refusing to sanction his best friend’s marriage.) Through Gretchen and Jimmy, and all of these snippets of the other characters’ lives, You’re the Worst announces that there are multiple paths toward happiness, which is a remarkably sweet and optimistic idea for a cynical series.

But just in case things seem a little too sweet, the finale makes sure it sets that montage to “No Children,” by The Mountain Goats, a song whose refrain declares “I hope you die, I hope we both die” and that NPR once called “the ultimate anthem to dysfunction.” “I hope the worst isn’t over,” John Darnielle sings in the song’s depressing lyrics, which run counter to the melody’s uplifting quality. “And I hope you blink before I do / And I hope I never get sober / And I hope when you think of me years down the line / You can’t find one good thing to say / And I’d hope if I found the strength to walk out / You’d stay the hell out of my way.” Then, in the bridge, Darnielle adds: “I am drowning / There is no sign of land / You are coming down with me / Hand in unlovable hand.” “No Children” was not written for You’re the Worst. But my God, it sure sounds like it was.

To the credit of Stephen Falk, the show’s creator who also wrote and directed “Pancakes,” You’re the Worst doesn’t reach its almost-but-not-exactly-happy ending without Gretchen reminding Jimmy that she has clinical depression and could, at any point, decide she’s going to jump in front of an oncoming train. The final moment in that montage — in which their crying infant daughter is wedged in bed between the two of them, while Jimmy sleeps and Gretchen sobs — suggests that her mental illness will be a real issue, but one that they will confront with at least some success. (They do make it to that wedding, after all, with their daughter clearly older and thriving.) Jimmy knows all this while they’re waiting for their pancakes and still says he wants to continue being with Gretchen. If she goes down, he is going down with her, hand in unlovable hand.

Really, we should have seen this coming, and not just because being noncommittally committed has always been Gretchen’s and Jimmy’s thing. The season-five premiere, “The Intransigence of Love,” actually told us everything about where the season would ultimately end. It stitched together a classic ‘90s rom-com narrative that was really an elaborate lie Gretchen and Jimmy were telling to a wedding planner, complete with a twist that suggested Jake, the version of Jimmy they concocted, had actually been alone, without a best friend, the whole time. (In real life, he ultimately does, at least temporarily, lose a best friend, but he is never alone.)

That episode took our understanding of love as shaped by millions of Hollywood movies and told us it was a fib. But at the end, Jimmy and Gretchen still walked out of that wedding planner’s office together, after Jimmy declared that his and Gretchen’s love story is the best kind because it’s “ugly and uncomfortable and haunting and brilliant and thrilling and yet, it’s messy and complicated. But it’s true. And that’s beautiful.”

As they leave, the camera focuses on a picture on the wall of a happily betrothed couple, one of the wedding planner’s former clients. It’s Jemma and Jake, the couple Gretchen and Jimmy invented in their fantastical version of a Kevin Smith movie. The image suggests it’s possible for some people to have that kind of narrative, one where they meet in a very ‘90s video store and get happily married. But for Gretchen and Jimmy, it won’t be because their story is, indeed, more messy and more honest.

In other words, as the first and last episodes of You’re the Worst reaffirmed: Their love story was the best, precisely because it was the worst.