How do you film futility? Movies are traditionally about action—getting the girl, winning the big game, accomplishing something. Screenwriters are taught from an early age the importance of giving their protagonist a goal, then loading him down with obstacles to overcome so he can achieve it. But not everybody gets what they want in life—how do movies deal with all the unhappy endings out there? A film like Inside Llewyn Davis finds dark humor in failure, but to treat futility—the eternal tilting at windmills—with utter seriousness is a far trickier proposition. How do you keep audiences on board when the character they’re following probably should have jumped ship long ago?

Writer-director James Gray’s deeply moving The Lost City of Z wrestles with these questions with such sincerity that, at first, it’s easy to assume that you know where it’s going. But what begins as a consciously old-fashioned adventure tale subtly, almost imperceptibly, morphs into something far richer, more mysterious and cosmic. By the time you realize the transformation has occurred, it’s too late—the movie has you in its clutches, and it doesn’t let go.

Based on David Grann’s 2009 nonfiction book, the film relates the odyssey of Percy Fawcett (Charlie Hunnam), a British officer desperate to make his name in the early 1900s. He gets his wish, sort of, when he’s assigned to explore the Amazon to chart this untamed region for the British Empire. Cartography wasn’t exactly Fawcett’s idea of how to achieve personal glory, but alongside his reliable assistant Henry Costin (Robert Pattinson) he snakes down the great river, encountering wary local tribes and, maybe, the signs of a hidden civilization older than any other on Earth.

Returning home with the news of his possible findings, Fawcett receives only smug skepticism, his cohorts refusing to believe that there’s a society that predates their own in such a “savage” land. Their dismissiveness only emboldens him, driving him to return to the Amazon again and again to find his lost city.

Drawing comparisons to Apocalypse Now and Aguirre, the Wrath of God, The Lost City of Z has been crafted by a filmmaker who knows and respects his film history. His 2013 romantic drama The Immigrant paid homage to The Godfather and silent cinema. 2008’s Two Lovers, in which a troubled Joaquin Phoenix wavered between Vinessa Shaw and Gwyneth Paltrow, appeared to have come from a vault in which forgotten 1970s character pieces had been locked away. Gray gravitates toward classical filmmaking, preferring an austere narrative style that’s crisp, precise, and sometimes a bit remote.

In its early reels, The Lost City of Z promises to be a smart but not exactly scintillating tale of a man seeking something he cannot find, undoubtedly journeying to some sort of metaphorical heart of darkness in which he’ll only come in contact with madness. Compounding this feeling is the presence of Hunnam as Fawcett. Best known for Sons of Anarchy, the actor hasn’t exactly jumped off the screen in films like Pacific Rim. His reserved performance here initially suggests a stiff-upper-lip restraint that prevents a deeper emotional connection to his character’s increasingly intense belief that somewhere in the Amazon isn’t just this lost city, but his destiny.

But that setup only hints at what Gray has in mind for this thematically ambitious tale. He lays the groundwork in quiet, unexpected ways. We’re familiar with films about adventurous, rugged men who go off seeking danger, leaving a supportive but worried wife at home. But The Lost City of Z adds its own wrinkles, introducing us to Nina (Sienna Miller), Fawcett’s beloved, who knows how much her husband is thirsting to prove himself in the world. At first, their separation is painful but accepted—the expeditions into the Amazon will take years—but with each return home, she’s a little different, and their relationship must evolve. Miller has played this sort of role before in American Sniper, but there are more layers to this character. She finds in them an understated essay on what “a woman’s place” was a century ago, as her love, resentment, and resignation begin to blur into one another.

Then there’s the way time itself is used as a weapon in The Lost City of Z. Fawcett doesn’t just explore the Amazon—as the years pass, circumstances at home force him to embrace other unwanted challenges. Gray riskily sends the character into other realms—and other genres of movies—and yet, they’re all connected to Fawcett’s burning belief that the jungles hold the key to his ultimate purpose. Shades of the political drama and the war movie enter into The Lost City of Z, not because Gray wants to flex his stylistic muscles, but because he’s hinting at something that his film will eventually make all too clear.

John Lennon once sang, “Life is what happens to you while you’re busy making other plans.” As Fawcett’s aspirations become more and more distant, his own movie starts to assert new demands on him that take him away from his original intentions. A loving adolescent son grows up to be an indignant young man, angry and ashamed at his old man for throwing his life away on some stupid dream. Older explorers who once seemed like role models prove themselves to be petty, selfish cowards. A world war rips through the fabric of a society, killing longtime friends. Fawcett doesn’t ask for any of it, but the movie, like life itself, keeps moving forward, changing him in the process.

As much as The Lost City of Z recalls earlier going-down-the-river dramas, I also thought of another group of films, those in which time and fate seem to be imposing their will on their main character. Whether it’s Stanley Kubrick’s Barry Lyndon or Mike Leigh’s Mr. Turner, there are movies in which the fundamental act of living a life starts to accrue a profound, hypnotic power. Fawcett grows older, still holding onto the belief that his lost city is out there waiting for him, and it’s touching watching Hunnam age into the role. The initial distance gives way to a melancholy and wisdom that, if we’re lucky, waits for all of us as we mature. But what good are maturity and wisdom if we never achieve the one aspiration we so desperately craved?

Over the course of decades—and more than two hours of screen time—Gray never reveals his own feelings about Fawcett’s quixotic quest. But while The Lost City of Z’s ending is open to multiple interpretations, it’s impossible to ignore its reverence for an individual’s desire to get lost in his dreams. Maybe that’s not futility after all—just a life lived fully.

Grade: A-

Grierson & Leitch write about the movies regularly for The New Republic and host a podcast on film. Follow them on Twitter @griersonleitch or visit their site griersonleitch.com.