Delusions of grandeur, old-fashioned ideals of romance and justice, the eternal clash between cynicism and dreams — these are the themes of not just comic hero Don Quixote but also the career of director Terry Gilliam, for whom a film about the ostentatious knight-errant seemed like the perfect match of artist to material, to the extent that he devoted a quarter century of his life to getting “The Man Who Killed Don Quixote” made. After setbacks more epic than anything described in the novel itself, Gilliam’s magnum opus exists at last, and the sad truth is, the reality can never live up to the version that has existed in his (and our) imagination for so long. If anything, it’s what the director’s fans most feared: a lumbering, confused, and cacophonous mess.

Opening with a wink — “And now … after more than 25 years in the making … and unmaking” — the film starts off on a promising foot. It teases us with Don Quixote’s most recognizable feat, jousting at windmills he has mistaken for giants, before revealing that we are in fact on the set of a TV spot for some Russian vodka brand (or maybe it’s insurance — the film is frustratingly unclear or downright inconsistent on many points). Once an ambitious young filmmaker, commercial hack Toby (Adam Driver) has effectively sold out, not only artistically but in his personal values as well — as when the director, asked by his boss (Stellan Skarsgård) to keep an eye on his beautiful young trophy wife (Olga Kurylenko), instead proceeds to seduce her.

Amid juggling the distractions of his comfortable yet meaningless existence, Toby is reminded of a black-and-white student film he made nine years earlier, also inspired by Cervantes’ classic novel, which sends him delving into long-forgotten memories of the humble shoemaker (Jonathan Pryce) he cast as Don Quixote and the 15-year-old village girl (Joana Ribeiro) with whom he innocently flirted at the time. Weirdly enough, until stumbling across a bootleg copy of the film, it doesn’t seem to have occurred to Toby that there exists a connection between his present project and this earlier one, shot just a stone’s throw from his current gig. As the details come flooding back, he feels compelled to follow up with these two actors.

Just outside the small Spanish town, Toby stumbles on the old cobbler, who — as revealed via flashback — has spent the intervening years believing that he is indeed Don Quixote. This being a Terry Gilliam movie, there’s a good chance that he’s right, or at least has some valuable perspective to impart upon the skeptical Toby, whom he mistakes for his “loyal squirrel” Sancho Panza. After all, in Gilliam’s two most acclaimed films, “12 Monkeys” and “The Fisher King,” the director blurs the lines between fantasy and reality, toying with the idea that perhaps only lunatics see the world for what it truly is. In those earlier projects, part of the fun came in trying to guess just how much had been a hallucination, whereas here, it’s all one big jumble.

What does the man who thinks he’s Don Quixote want? And what service does Toby provide by going along with the charade — which he does in some scenes while strenuously objecting in others? When a filmmaker has as many years as Gilliam did to think about a project, one expects all that time for reflection to help in clarifying what he intended to say all along. Plainly, there are elements of autobiography at play (like Toby’s character, Gilliam must have revisited the people and places who participated in the version maudit chronicled in Keith Fulton and Louis Pepe’s fascinating what-might-have-been documentary “Lost in La Mancha”). But it’s terribly unclear whether Gilliam identifies with either of his protagonists — the jaded young director grappling with the emptiness of his career or the foolish old coot uniquely capable of recognizing adventure in a world stripped of magic. Each is unpleasant to be around in his own way, while an ill-fit romance with either or both Ribeiro’s and Kurylenko’s characters feels grafted on and incoherent.

Beneath a grizzled beard and beak-like prosthetic nose, Pryce makes a fine-looking Don Quixote (a role for which Gilliam worked with many actors, including Jean Rochefort and John Hurt, both acknowledged in the end credits), but his sonorous voice starts to sound like a braying donkey, given the over-loud levels at which the film is mixed. Combine that with Driver’s antic performance as the exhaustingly incredulous Toby (which sorely lacks the quixotic comic touch that Johnny Depp would have brought), and the whole experience feels like a recipe for a migraine.

It doesn’t help that Driver’s dialogue requires him to drop more F-bombs than a David Mamet character, dooming the whole slapsticky enterprise — which clanks and honks with the sort of off-kilter energy only children seem to appreciate — to an inevitable R rating (early on, Toby even insists on using the F-word in his TV commercial … as if it’s totally normal for expletives to find their way into advertising campaigns). If only such an easy fix might transform this misbegotten project into something commercial. Alas, Gilliam remains his own worst enemy, insisting on artistic freedom while lacking in many of the fundamental skills expected of a director (from basic screenwriting to getting consistent, relatable performances from gifted actors) to sustain our interest once things start to go off the rails. The trouble starts about 20 minutes in, around the time Don Quixote murders two Spanish police officers he mistakes for “enchanters” — a word you will never want to hear again, so long as you live.

To Gilliam’s credit, no one creates characters as spectacularly unhinged as he does, giving us over the course of his career such larger-than-life nutjobs as Baron Munchausen and Hunter S. Thompson — although they so often wear out their welcome. In theory, Don Quixote should be a welcome addition to the stable, but what wouldn’t we give for an interpretation of the crazy crusader who treated his quests as something more than the silly ravings of a colorful eccentric? Early in the film, one of Toby’s cohorts warns that “we become what we hold on to” — a line that may as well be an open admission on Gilliam’s behalf of a certain kinship he feels with the character, although the result feels like evidence of someone who spent too long obsessing over Don Quixote, eventually losing sight of whatever attracted him in the first place.