The director of "Ain't Them Bodies Saints" and "Pete's Dragon" synthesizes his filmmaking strengths with this inventive supernatural tale.

The main special effect in “A Ghost Story” is older than the movies: After a young Dallas musician (Casey Affleck) dies in a car crash, he returns as a ghost to the home he shared with his wife (Rooney Mara), and he’s draped in a sheet with hastily made cutout eyeholes, like some misbegotten Halloween costume.

Yet writer-director David Lowery channels the absurdity of this setup into an extraordinary mood piece that amounts to his best movie yet. Lowery has quickly developed a filmography that mines for awe in solitude, and here delivers a cosmic variation on that theme, exploring the ineffable relationship between people and the meaning they give to the places that have value in their lives. Both formally ambitious and emotionally accessible, “A Ghost Story” transforms its main stunt into a savvy dose of minimalism with existential possibilities that cut deep.

That’s unsurprising for a filmmaker who cut his teeth with microbudget fantasies like “St. Nick” and a variety of adventurous shorts before exploring a bigger commercial arena — first with the lyrical crime saga “Ain’t Them Bodies Saints,” and then on the even grander scale of Disney’s live-action “Pete’s Dragon” remake. Those movies hit their delicate beats with the elegance that’s at the root of Lowery’s talent, but “A Ghost Story” shows the extent to which he has gained confidence in his approach. As the ghost bears witnesses to a world that passes on without him, Lowery delivers a fantastical vision rich with feeling and curiosity over the mysterious forces governing everyday life.

An opening quote from Virginia Woolf’s “Haunted House” sets the stage, and the film opens with tidbits of the couple squabbling about whether they should move out of their remote home on the outskirts of the city. Despite their disagreements, they seem to maintain a fairly comfortable, affectionate chemistry even as an eerie atmosphere hovers over their home. Lowery’s camera lurks as an orchestral score swells, the dramatic effect out of sync with the mundane setting (it only makes sense in the context of information revealed much later). In a series of understated beats, Affleck’s character is lying dead in a hospital, the victim of an off-screen car crash, and his lover is staring down at him in wordless shock. But after she exits the frame, “A Ghost Story” stays with the corpse, who suddenly rises up and takes center stage.

It’s here that “A Ghost Story” threatens to collapse into the silly nature of its premise, but Lowery wastes no time establishing a function to the ghost’s travels. Away from hospital, the phantom journeys across a sweeping green landscape, viewed from afar as if haunting the center of an Edward Hopper canvas. Back home, he launches into a voyeuristic saga, watching from the corners as his widow copes with the grim situation. Faster than you can conjure up memories of Patrick Swayze in “Ghost,” however, Lowery makes it clear that he won’t settle for dime-store sentimentalism. In a bold sequence that risks alienating his viewers, Lowery watches Mara stress-eat her way through an entire apple pie, while her invisible company looks on. It’s one of several moments in which “A Ghost Story” completely upends expectations; at no point does the movie land on a predictable beat.

While Lowery gives the specter some ground rules, including the ability to toy with electricity and move objects when he’s whipped up into a frenzy, he’s largely a passive witness. He sees more than one new resident in his former home, and even befriends a ghost next door. Sustained by a wondrous score and warm colors, “A Ghost Story” is a textured experience that rushes ahead at an increasingly engaging pace.

Lowery’s first collaboration with cinematographer Andrew Droz Palermo (“Rich Hill”) is distinguished by the fluid rhythms that tip each scene into the next with a series of brilliant transitions. Time moves forward in surprising ways: Mara passes through one room several times over, the ghost wanders through empty rooms and into others suddenly populated by lively characters, and at times his surroundings morph into new shapes as the timeline contorts. Through it all, he remains adrift in an enigmatic process of silent observation, his relationship to his surroundings implied by only subtle gestures. Early on, Mara’s face tells much of the story, and Affleck’s appropriately muted in the handful of moments where he’s visible, but they’re only a small part of the ensemble that comes and goes as events speed up and lurch in a series of unpredictable directions.

Among the standouts is Lowery regular Will Oldham (star of the director’s acclaimed short “Pioneer” and a composer on “Pete’s Dragon”). Just as his bizarre tale in “Pioneer” transformed a simple concept into something unexpectedly profound, Oldham’s energetic monologue in “A Ghost Story” takes this storybook fantasy into enlightening intellectual terrain, as he grapples with Beethoven, crises of faith, the end of the world, and the healing power of art. The rambling speech, delivered at a house party to baffled guests, might suffer from being on-the-nose, but it’s so vivid it has the same effect as the white sheet lurking nearby. It levitated above the inherent absurdity of the situation with poetic conviction.

No matter its odd twists, from abrupt transitions to muted scenes defined by inaction, “A Ghost Story” is always going somewhere. Lowery’s command of the medium is so precise that the movie often gets away with far more than any basic description would suggest. Its central drama, a romance complicated by unremarkable troubles, risks turning the movie into a twee relationship drama at one point and a hackneyed tale of missed opportunities at another, but Lowery seems to be aware of these trappings. Watching “A Ghost Story,” part of the fun stems from Lowery’s ability to navigate potential clichés. It’s a worthy gamble.

The appeal of “A Ghost Story” is all the more impressive in the wake of “Pete’s Dragon,” a movie Lowery made on an unfathomably larger scale and designed for mainstream appeal. But even as “A Ghost Story” exists in a niche, it’s not preaching to the converted; Lowery manages to find entertainment value and genuine intrigue from his outlandish scenario, synthesizing the magical realism of his earlier films with a tighter grasp of tone. With “St. Nick” and “Ain’t Them Bodies Saints,” Lowery showed plenty of craftsmanship but leaned too heavily on the Terrence Malick playbook, reveling in gorgeous landscapes and whispery dialogue at the expense of innovation. “A Ghost Story” allows Lowery to build on those dreamy tropes with a voice of his own. The result is a soul-searching drama in which powerful revelations emerge less from a satisfying destination than from the beautiful struggle involved in getting there.

Grade: A

“A Ghost Story” premiered in the NEXT section of the 2017 Sundance Film Festival. A24 will release it theatrically later this year.

Sign Up: Stay on top of the latest breaking film and TV news! Sign up for our Email Newsletters here.