Wolverine (Hugh Jackman) watches over multiple generations, including young Laura (Dafne Keen), in the new “Logan.” (20th Century Fox)

Caveat: Minor spoilers ahead.

IN THE MIDDLE of the new film “Logan,” as Wolverine is on the run, we glimpse on a television a scene from the classic 1953 Western “Shane.” The allusion could not be more fitting.

In George Stevens’s moving mid-century film, the title gunfighter becomes a more sympathetic character as we see his increasing attachment to a threatened homesteading family in post-Civil War Wyoming. Shane, as played by Alan Ladd, insists on replacing the rancher father in a showdown with hired guns — in part because of Shane’s affection for the entire family, including the wife and son. The boy idolizes the ever-roaming gunslinger, but “father figure” is not a role that Shane can stick around to fulfill; all he can do is be willing to sacrifice himself for their safety.

What better window into the swan song of Hugh Jackman’s Wolverine?

In the new film, Logan the killing machine is not only surrounded by his makeshift family of mutants; he also is willing to fight for a rural human family whose plight — standing up to hired muscle who are trying to intimidate upstanding folks off their land — directly reflects the plot of “Shane.”

The effect of placing Logan within these twin families is to greatly humanize a character who can sometimes look far too feral to feel sympathy for.

And what director James Mangold capitalizes upon, in his second solo Wolverine outing, is Jackman’s ability to bring profound humanity to this role.

When a virtually unknown Jackman was first fitted with Adamantium claws — for 2000’s “X-Men” — he became like a surrogate son to Professor X (Patrick Stewart). In “Logan,” that rich history is mined beautifully, as Wolverine inherits the dual roles that so many real-life Gen-X’ers and late boomers now find themselves in: serving as a caregiver to a parent while also trying to raise a child.

In this case, Logan is the reluctant sudden father figure to X-23/Laura (Dafne Keen), a lab-raised mutant girl who — with claws as fast as “Daddy’s” — can slice and slash for her own survival. She is the child who is coming into her own power, yet still needs a parent to show her the ways of the world and to guide her along her long journey.

And so Logan leads his three-generation family through perilous Southwestern landscapes (this is a sci-fi Western as much as a superhero film, after all), as they seek sanctuary near the Canadian border.

All the while, Logan — his skeletal Adamantium seeping into his skin like a slow poison — is ever aware of his mortality. As a parent, he is willing to do whatever it takes to secure the safety of his would-be daughter, including the endurance of excruciating sacrifice. If that means trading in one kind of poison for a more constructive type, he eventually accepts that role — in contrast to Professor X, who, like a beatific grandfather, embraces Laura from the very start.

The circle of parental life feels powerfully complete in “Logan.” Even in the most violent mutants, there is humanity to stir the movie-going soul.

Read more:

‘Logan’ is the Wolverine movie Hugh Jackman always deserved