We know D.C. Get our free newsletter to stay in the know.

Farrell, sporting the same greasy ponytail and mustache, looks as though he walked directly from the Crazy Heart set to film The Imaginarium of Doctor Parnassus. Farrell was a last-minute addition to the project, after Heath Ledger’s death prompted director Terry Gilliam to finish the film with Farrell, Johnny Depp, and Jude Law as rotating stand-ins for his deceased star. The shared-character trope has been jarring at worst (Palindromes) and odd at best (I’m Not There, the Bob Dylan biopic in which Ledger also played a fragmented role). Here, though, the transitions not only work but make sense in the context of Gilliam’s dense story about a magic man, his traveling road show, and a looking glass that transforms anyone who walks through it.

The film as a whole isn’t quite as successful, a visual and narrative whirlwind that’s too scattershot to engage and is a disappointing finale to Ledger’s career. It’s difficult to grasp the gist of the plot among all the literal smoke and mirrors: In present-day London, an olde-tyme vaudeville act pops up featuring with Valentina, a lovely, Victorian-clad Kewpie doll (Lily Cole), Percy, a “little person” (Verne Troyer), and Anton, a face-painted barker (Andrew Garfield). “Let Dr. Parnassus open your imagination; let him transport you!” Anton cries, as Parnassus (Christopher Plummer) meditates onstage, in robes and a white beard, looking old as time itself. In truth, he nearly is: Parnassus had long ago made a deal with the devil (Tom Waits), granted youth and immortality in exchange for handing over any of his future offspring on his or her 16th birthday.

How exactly Parnassus is able to “open your imagination” is a mystery to both passers-by and viewers, but it involves a mirror that leads those who dare enter it into a fantasical world in which both bliss and damnation can be found. More important, though, is the Faustian deal: Valentina is nearly 16 and unaware of her fate. But Satan, here called Mr. Nick, offers Parnassus a chance to keep his daughter with another wager, this one involving which of them can, er, suck five souls into the netherworld first. Or something. Ledger’s character, Tony, enters the picture when Valentina and Anton find him in a noose over a bridge. (Yeah, the sight—the actor’s first scene—isn’t pleasant.) Tony has amnesia but quickly proves himself adept at charming people into seeing the show and, ideally, entering the mirror. There are hints that his past isn’t an honorable one, involving a children’s charity that’s really a front for money-laundering.

Got that? It hardly matters. Gilliam is all about the fantasy, and The Imaginarium of Doctor Parnassus is often a ravishing spectacle full of surreal scenes: free-standing ladders that stretch to the sky, verdant fields and creeks that look straight out of a Monet, and, in a particularly Monty Python-esque scene, a giant head that unleashes a chorus line of singing and dancing bobbies, some of them in drag. Backgrounds fracture like glass and peaceful images wither to gray menace as Mr. Nick takes over this otherworld. The film is a perfect candidate for 3-D, but kudos to Gilliam for not trying to milk an overly trendy cash cow.

But it’s all sound and fury. You’ll never be bored by the film, yet there are too many WTF? moments and messy plot turns to recommend it. Ledger’s character is too murky for his performance to be remarkable. (Though Depp, in his short amount of screen time, adds some welcome whimsy.) Gilliam’s most impressive achievement is delivering a movie that doesn’t seem like it had to be reimagined and patched together mid-production. But when it ends with not a director’s credit but “A Film From Heath Ledger and Friends,” a melancholic sentimentality is all you’ll likely take away from it.