Logan is a punch in the gut in all the right ways. Onscreen, the X-Men series has always found ways to morph and expand, from time-traveling fantasy to social allegory to political thriller. And it’s done so as other comic-book franchises have ossified, with the DC movies (foolishly) doubling down on flamboyant gloominess and Marvel proper (lucratively) committing to jokey spectacle. Constant redefinition may be more risky financially — you never quite know what you’re going to get — but when it works, it can be beautiful. In Logan, we have an example of a superhero story taken to new extremes and a franchise to a spare, sad, apocalyptic finish (or “finish”), with R-rated action scenes that are both rousing and unbearably violent.

We open on a drunk, out-of-it Logan, aka Wolverine (Hugh Jackman), waking up to a group of dudes trying to jack his limo — and then slaughtering them when they won’t stop. The year is 2029. Logan keeps a low profile working as a driver-for-hire. He lives in an abandoned smelter south of the border, where he takes care of a delusional, ailing Professor Charles Xavier (Patrick Stewart) inside a collapsed water tower with help from an albino mutant-tracker named Caliban (Stephen Merchant). Something in this future has clearly gone wrong with the X-Men, and with humanity.

Professor X, as he was once known, is losing his mind in the worst way possible: He has seizures that can level city blocks. We learn that one, a year ago, injured 6,000 people and killed a few of the remaining X-Men. (“A degenerative brain disease in the world’s most dangerous brain. What a combo,” one bad guy observes, and it’s hard to disagree.) Meanwhile, the evolutionary revolution has died out: No new mutant has been born for 23 years. “We thought we were all part of God’s plan,” Logan tells his former mentor. “But maybe we were God’s mistake.”

Into their dying world steps a former nurse named Gabriela (Elizabeth Rodriguez) and a young, mute girl named Laura (Dafne Keen). Gabriela’s trying to protect Laura from a group of deadly soldiers — called “reivers” — who also have been harassing Logan. Turns out that Laura is a mutant — a lab-created, rage-prone killing machine with retractable blades in her hands, just like Logan himself. The men who created her want her back. But Gabriela, the nurse who helped raise her, hands the girl off to the bitter, forgotten superhero, who understands better than anyone else what’s going on in the child’s mind. Away they go toward North Dakota, where they’ve been told a place called Eden offers escape across the border into Canada and to some kind of safety.

Reluctant protagonists are nothing new, and certainly not in superhero movies. But most of the time, once the lead characters take up a cause, they tend to go all in, and the films transform into resplendent tales of heroism and nobility. Logan, however, holds to its melancholy, elegiac vein. Even as he racks up an impressive body count, Wolverine refuses to believe in the worthiness of his cause or the possibility of hope.

EXPAND Courtesy of 20th Century Fox

This so-called Eden, he’s convinced, is a sham, an imaginary sanctuary Laura and Gabriela got from reading too many Uncanny X-Men comic books. (That’s right, in this least comic-booky of X-Men movies, there are actual X-Men comic books.) In a motel room, Laura catches George Stevens’ Shane on TV, and while the reference feels appropriate — Logan probably owes more to Westerns than to superhero flicks, with a bit of Firestarter, Children of Men and Terminator 2 also thrown in — we may be struck by how little our nihilistic lead behaves like Alan Ladd’s romantic, all-American drifter in that 1953 classic.

If there is an inconsistency in Logan, it’s this: The remorselessly desolate tone can feel, at least on the surface, like a rejection of the X-Men films’ largely congenial, collective spirit, even as the filmmakers mine the goodwill left from that series to color in their characters. We care about Professor X because we know who he once was, and we care about Logan because we know who he could be again. (Even the constant swearing feels like a rebuke to the earlier movies: Logan features so many “fucks” it approaches Deer Hunter levels of profanity.)

But maybe that’s also why the film works so well. The dead-end despair comes not just from what’s onscreen but from a vague memory of a better past. Logan is not so much a refutation of those earlier pictures, but their cautionary flip side — a sign of what happens when a community falls apart, cooperation is no longer possible and the bad guys have all but won.

More than any other superhero franchise, the X-Men movies play more with their characters’ vulnerabilities than their strengths. The mutants have amazing powers, but most of the time, they’re harried, hounded and haunted. Seen from that perspective, Logan isn’t so different after all. From the doddering, invalid Professor X to the alcoholic, broken hero left to rot among his demons and the young girl unable to control her rage, the story takes three unwell people and shows us how they need each other. Ultimately, it is their growing bond that proves most fascinating and moving about this film. Somewhere amid all that foul-mouthed carnage, a sense of humanity still shines through.

