A space western and a blissed-out cosmic high, “The Martian” stars Matt Damon as an American astronaut who, like a latter-day Robinson Crusoe, learns to survive on his own island of despair. At once epic and intimate, it involves a dual journey into outer and inner space, a trip that takes you into that immensity called the universe and deep into the equally vast landscape of a single consciousness. For this accidental castaway, space is the place where he’s physically marooned, but also where his mind is set free — a dynamic that of course invokes moviegoing itself.

Perhaps that’s one reason Ridley Scott keeps returning to deep space. This is the third of his films — after “Alien” in 1979 and “Prometheus” in 2012 — set beyond the dark side of the moon. Hands down it’s also the funniest, loosest and most optimistic of the group, at once an ode to far-out adventuring and to terra-firma home, a sweeping, old-fashioned entertainment and a plaintive portrait of solitude as both a creative necessity and a danger. It also serves as a nice plug for NASA, which has returned the favor by pushing the movie on its website. (On Monday, scientists announced that signs of liquid water could be seen in photographs taken on Mars by a camera on the Mars Reconnaissance Orbiter, timing that suggests NASA certainly has the whole cross-promotion thing down.)

Based on the novel “The Martian” by Andy Weir that Drew Goddard has turned into a fast-moving, streamlined script, the movie focuses on Mark Watney (Mr. Damon), who, during a windstorm on Mars, is accidentally left behind by his team. Mr. Scott likes the action to hit hard and fast: One minute Watney is joking with his space buddies — Jessica Chastain leads a crew that includes Kate Mara and Michael Peña — and minutes later he’s been hooked like a fish by some flying metal that knocks him out. Believing him dead, the crew takes off, as does the movie, which soon becomes a tale of two planets with initially competing narratives, one involving Watney’s efforts simply to stay alive and the second centered on NASA’s postdisaster strategizing.

After some self-surgery to deal with the rod spearing his gut, along with some anxious stock-taking — he has plenty of tunes but not enough air, water and food to survive for long — Watney gets down to the business of living, including farming. “I’m not going to die here,” he helpfully mutters, helpfully because he talks out loud a lot whether just murmuring to himself or recording a video entry in his growing space log. The log keeps the words flowing in what could have been a fairly quiet movie, creating an animated lively babble that approaches the chummy feel of a video face chat. Watney makes for affably pleasant if worrisome company, and if there isn’t much mystery to him it’s because the purity of his struggle doesn’t leave him, at least, time for deep dives into questions of existence.

Image

In “The Martian,” directed by Ridley Scott in an adaptation of Andy Weir’s novel, Matt Damon plays an astronaut accidentally left behind by his team on Mars.CreditGiles Keyte/20th Century Fox

Although Watney is isolated at first, with no means of communicating with Earth, the parallel narrative means that he’s never truly alone, unlike, say, Crusoe (before Friday) or Tom Hanks’s character in “Cast Away” (before Wilson), whose profound isolation is critical to how you experience them and their stories. Like these other marooned souls (including the 1964 “Robinson Crusoe on Mars”), Watney is physically and psychologically apart, but even before he pings Earth with his big news, you know people are mourning him. The Earth scenes interrupt these solitary interludes with other faces and voices, keeping the narrative jumping, but they also assert that no matter how lost and seemingly forgotten, no one is alone because to be human fundamentally is to exist with other people. We are social, therefore we are.

Gradually, the two stories become one as Watney and everyone else gets to work. At NASA, various brainiacs take hammers and tongs to physics at both the Johnson Space Center and the Jet Propulsion Laboratory, where supernerds take on the logistics of a rescue mission. The movie gently thumps several issues: It’s unambiguously on the side of science and rationalism with glints of manifest destiny, American can-do-ism and a little flag-waving folded in. It is also about willing yourself out of the lonely room — call it Mars or your head — and into the world, however inhospitable, so you can breathe the air and drink the water (Watney learns to make both) and yearn for others. It’s a moving testament from the 77-year-old Mr. Scott, whose art comes in all shades of dark.

Here, by contrast, he seems almost giddily attuned to the buzz of human endeavor. The NASA scenes with their friendly, familiar faces — Chiwetel Ejiofor, Kristen Wiig and Jeff Daniels — unfold with charming predictability with corrugated brows, hushed and raised voices, acres of glowing screens and warehouses of space stuff. The vibe is of serious, smart people doing serious, smart work for the good of the rest of us. Mr. Ejiofor’s enormous, pleading eyes signal how grave the situation is, while Ms. Wiig’s prickly warmth and Mr. Daniels’s Daffy Duck mouth-flapping keep the whole thing from getting too heavy. Mr. Scott is a brilliant assembler of casts, and he knows how to organize groups so they seem to naturally fit, and can bob and weave in unison with his roving cameras.

Unlike some advertising directors who transitioned to filmmaking, he has always been a good director of actors, though it’s instructive that he uses performers who are either forceful enough screen presences or strikingly beautiful enough (usually both) to stand up to his lush visual style, who can meet the challenge of his meaningfully complex sets and natural vistas. When the film works, the bold drama of his visuals and the dramatic boldness of his stories flow together, becoming all of a narrative piece. Some of these pieces resonate with other meanings, like the red-rock buttes in “Thelma & Louise” and the similarly rust-colored formations in “The Martian” that are suggestive of John Ford’s Monument Valley films. Sometimes here, Mr. Scott seems to be returning to his own work, which may be why you can see Susan Sarandon (Louise), with her protuberant gaze and thin-skinned tremulousness, in Mr. Ejiofor. And of course Mr. Scott loves tough women, so it’s no surprise that Ms. Chastain and Ms. Mara are on board.

“The Martian” has sweep but not the vanity that creeps into many large productions, turning them into bloated vehicles for directorial self-aggrandizement. Mr. Damon’s Everyman quality (he’s our Jimmy Stewart) helps scale the story down, but what makes this epic personal is Mr. Scott’s filmmaking, in which every soaring aerial shot of the red planet is answered by the intimate landscape of a face. There’s a touch of Cecil B. DeMille in his cinematic DNA (for better and occasionally for worse), though, like many who saw “2001: A Space Odyssey” during their esthetically formative years, there’s even more Stanley Kubrick. But Mr. Scott is very much his own artist, one whose reputation as a visual stylist has at times obscured that his great, persistent theme is what it means to be human.