In the world of film character actors, there aren’t many to compare to the late Harry Dean Stanton. When he passed away last month at age 91, he left a huge legacy of work. His career was remarkably prolific, diverse and impressive, from “Cool Hand Luke” (1967) to “Alien” (1979), from “Repo Man” (1984) to his leading role in “Paris, Texas” (1984).

Friday saw the nationwide opening of his last film, the independent comic drama “Lucky.” His farewell performance gives Stanton a final starring turn as the title character, a very personal role as a cantankerous, reclusive man living on the edge of a small Arizona town.

He plays an aging atheist who sees the scattered stardust of the Big Bang rather than a deity as the source of our life. He tells most of his acquaintances, “You’re nothing.” Confronting his own mortality and advancing toward a kind of spiritual enlightenment, he moves among quirky characters played by Ron Livingston, Tom Skerritt, Beth Grant, Ed Begley Jr. and David Lynch, who directed him in several projects, including “The Straight Story” (1999), “Wild at Heart” (1990) and this year’s TV series “Twin Peaks: The Return.”

In “Lucky,” Stanton was directed by another notable supporting player. It’s the debut feature from John Carroll Lynch, who worked at the Guthrie Theatre for eight seasons before appearing in “Fargo” (1996) as the stay-at-home wildlife artist husband of pregnant cop Marge Gunderson (Frances McDormand). The Coen brothers film won him national attention leading to a nonstop string of on-screen appearances in iconic roles almost as notable as Stanton’s.

Lynch expected that he would act in “Lucky” when his screenwriter friend Logan Sparks and co-writer Drago Sumonja asked if he was interested in working on their project, which is largely based on Stanton’s personal life experiences and philosophy. “I said, ‘Yeah, four days with Harry Dean sounds like fun. Sure, I’d be happy to do that,’ ” Lynch said during a recent visit to the Twin Cities.

Then the original director dropped out. With the project about to get going, they asked in 2015 how he would feel about directing it instead. Saying yes meant that Lynch’s commitment to the movie grew from less than a week to two years, sandwiched into a nonstop schedule of TV and film acting commitments elsewhere.

Nonetheless, it wasn’t a tough decision. Although Lynch has had a stellar career in front of the camera, he long wanted to move behind it. He found the offer impossible to resist, although “the last thing I directed was a play in college.

“Actors want to stretch. They want to tell stories that don’t fit their bodies. The opportunity for me to tell stories with a character who doesn’t have to be 6-foot-4, 250 pounds, is really helpful, an extension of the desire to experience other people’s lives.” He found the story of a self-sufficient old near-hermit “really evocative to me and important and universal in its own way but really specific about this individual person.”

Even late in his life, Stanton was a consummate professional.

“I had just done an 18-day scheduled shoot, which was the same as ‘Lucky,’ as an actor,” said Lynch. “I am half his age and twice his size, and I was exhausted and confused” by the demanding schedule. “Everything we did was to do two things: to husband Harry Dean’s energy, and to make sure he was as comfortable mentally and physically and spiritually as possible. Although he wouldn’t say spiritual because he didn’t believe in it.

“He was very brave. In one of the scenes from ‘action’ to ‘cut’ he walked 3 ½ miles as an 89-year-old man. That was one of the days I said I think we should subtitle this ‘Lucky, or How to Torture an 89-year-old Man.’

“But he was in it. Because of physical energy and emotional energy, there were lots of struggles that way, and also the vulnerability of the material because it was personal to him.”

The film raced through two weeks of shooting along the rural borders of Los Angeles, with one more day devoted to capturing scenic Arizona landscapes. Filming there made it feel as if Stanton was reprising the wonderful role as a desert-rat romantic that he played in “Paris, Texas” three decades earlier. “Once you do that you evoke those vistas that [director] Wim Wenders captured so beautifully,” Lynch said.

Lynch feels that despite the box office appeal of roller-coaster movies, the films that matter over time “are the ones that said something to me. I like to be taken into a world, taken into a person’s life and then follow the journey. I feel that we are hungry for something else.”

While Lynch only knew Stanton for a relatively short time, he feels deeply touched by his death after filming him in a story with mortality as its subtext.

“Here is what I can say. This movie was conceived as an elegy for Harry Dean Stanton. It has now, to some degree, become a eulogy. Losing Harry just before the premiere was hard. Others who worked on the movie — Ed Begley, David Lynch, Logan Sparks and others — were longtime friends of Harry’s. My emotions do not reach the depth of loss that those who loved him for longer and more deeply have felt. My feelings are personal, too. Those I can’t quantify.”

Ultimately, he feels that their work together “can bear that weight. And from Harry Dean’s perspective it doesn’t change it all. In either case, we are nothing. Regardless of whether I agree, it is a good perspective. So honored to have worked with him.”