The Wolverine trilogy spun off from the “X-Men” movies comes to a grim, violent but redemptive end with “Logan,” which tips its hand to such western forbears as “Shane” in giving its antihero-with-retractable-metal-claws the unwanted responsibility not only to care for an aged, mentally deteriorating Professor Xavier (Patrick Stewart), but to protect a little mutant girl named Laura (Dafne Keen), who may just be his daughter, from an army of brutal corporate soldiers and take her to a sanctuary for her kind called Eden. Collaborating with co-writers Michael Green and Scott Frank, director James Mangold—who also helmed 2013’s “The Wolverine”—gives Hugh Jackman’s Wolfie a smoothly-executed but hard-R sendoff that arguably represents the high point of the actor’s nearly two-decade run in the role.

The film is set in 2029, with Logan an aging, bleary-eyed, alcoholic shadow of his former virile self, though—as a prologue demonstrates—he can still survive bullets and beatings to rouse himself, when angered, to take care of a gang of car thieves. He works as a limo driver—a job he clearly detests—in order to make the money that allows him to buy meds that help control the periodic—and damaging—seizures that Xavier suffers from. While plying his trade in Texas, he keeps the professor isolated in a metal tower at an abandoned smelting plant across the border in Mexico, where another mutant, the albino mutant-tracker Caliban (Stephen Merchant), who can’t tolerate sunlight, helps care for him.

Two unwelcome visitors disturb Logan’s routine. One is smoothly threatening Donald Pierce (Boyd Holbrook), who works for Dr. Zander Rice (Richard E. Grant), the head of Transigen, a company conducting nefarious experiments that, as it turns out, are aimed at creating an army of super-soldiers. The other is Gabriella (Elizabeth Rodriguez), a former nurse at Transigen’s Mexican facility, who helped save a bunch of child clones Rice had decided to terminate as failed subjects after his X-24 project, which resulted in a more powerful but hard-to-control version of Logan himself, was successful. Gabriella offers Logan $50,000 to drive Laura, one of the survivors, to a site in North Dakota where, according to a story related in an old X-Men comic, those like her are gathering to flee across the border to Canada.

Logan refuses the mission, but when Pierce shows up at the smelting plant with an army of well-armed thugs and lots of corrupt cops—resulting in a protracted battle in which the mute girl shows off her powers—he must take to the road with her and Xavier in tow, heading north toward the Eden he believes to be a comic fiction. Unfortunately, Pierce has captured Caliban and forces him to track the fugitives.

The result is naturally some big action set-pieces along the way. One occurs at a Las Vegas hotel where the trio briefly hole up and Xavier and Laura watch “Shane” together. The other is set at a farmhouse where they’re taken in for the night by a helpful rural family, the Munsons (Eriq La Salle, Elise Neal and Quincy Fouse), with results that are unfortunate when Pierce and Zander show up along with X-24. Nonetheless there will be a final confrontation near the Canadian border, in which Logan rediscovers his old mojo, though at a terrible cost.

This is a relatively thin narrative to be stretched out to 139 minutes, but Mangold is a solid craftsman, both in terms of the script and his direction. This is a far more concentrated and intense effort than the overly busy (and rather silly) “Wolverine,” even though some of the fight sequences go on a bit longer than ideal (editors Michael McCusker and Dirk Westervelt might have employed the scissors with the same level of aggression that some of the stuntmen demonstrate). The cast give him their all. Jackman anchors things with a turn that leaves no emotion untouched (he also plays X-24 with some digital assistance), and he works exceptionally well with Stewart, who brings both pathos and dignity to the addled Charles Xavier, and Merchant, who makes Caliban a figure both sad and oddly admirable. Even the villains are more interesting than usual: Holbrook is silkily malevolent as Pierce, while Grant refuses to go over-the-top as Rice, making him all the more awful for his composure. La Salle, Neal and Fouse give some real human dimension to their extended turn, and Keen is a genuine find, able to hold her own even with the commanding stars. Needless to say, this is a thoroughly polished production, with cinematographer John Mathieson’s widescreen images taking full advantage of both Francois Audouy’s fine production design and some expertly-chosen locations, especially in the closing reel.

“Logan” may sadden some fans because of the grave losses to the “X-Men” roster suffered in the course of its narrative. But don’t be too disturbed: this is a franchise that has gone all over the temporal map with prequels and spin-offs, and doubtlessly has many more possibilities up its sleeve.

In the meantime, make sure that you see “Logan” from the very beginning. Fox is providing Marvel fanatics with an offbeat treat even before studio logo comes up, and you won’t want to miss it.