We’re off to meet the wizard: before he became the mythical man behind the curtain, the great and powerful Oz was a mere con-artist conjuror named Oscar Diggs (James Franco), who worked the early-20th-century sideshow circuit. He’s an expert at smoke-and-mirrors misdirection, as well as a practised lothario (he seduces his tenuous objects of affection with a tchotchke music box and a devilish grin). But Oscar nonetheless longs for something more – for the ‘greatness’ he sees in people like Thomas Edison, whose inventions (from the incandescent lightbulb to the Kinetoscope) have given mankind a literally illuminative sense of faith.

It’s an earnest hope, to be sure, and the greatest strength of Sam Raimi’s imaginative, if highly uneven, take on L Frank Baum’s series of children’s stories about that magical land over the rainbow is its unabashed sincerity. Right from the opening credits – designed to resemble handheld stage props popping out from behind a seemingly infinite series of prosceniums – it’s clear the Spider-man helmer’s heart is fully in this big-budget 3D project. The feeling persists through the leisurely paced Kansas scenes (gorgeously photographed to mimic the Academy-ratio sepia tones of the 1939 Judy Garland perennial), which do a lovely job of introducing all the real-world characters that have a metaphorical Ozite counterpart. Then the inevitable tornado hits, whisking Oscar away to the widescreen Technicolor world he is prophesied to rule, and the movie’s rock-solid footing starts to wobble.

Most of the problems stem from the casting: Franco is a distinctly uninspiring Oz, which works for the early scenes, but is near disastrous when he assumes his predestined roles of liberator, saviour and big giant head. The actor’s two default modes – stoned indifference and performance-art aloofness – do not an invigorating leader make. Equally off-key is Mila Kunis as the glamorous enchantress Theodora, who turns into one of the Oz series’s most memorable antagonists after Oscar breaks her heart. (Let’s just say Margaret Hamilton would not be green with envy at this screechily anemic pretender to her wicked throne.) And while Rachel Weisz and Michelle Williams do their best catty-sister act as Theodora’s siblings – the evil witch Evanora and the good witch Glinda – they are ultimately no more than action-figure props made to engage in by-the-numbers showdowns better suited to a Star Wars prequel.

That Raimi manages to make something of Oz the Great and Powerful despite all these and other obstacles inherent to a Disney-financed superproduction is close to a miracle. A good part of that has to do with the Rorschach-blot power of Baum’s creation: like Oscar or the series’s other constant protagonist, Dorothy Gale, whose family is briefly referenced here, the land of Oz morphs to fit the mind-set of the outsiders inhabiting it – character and creator alike. Though the filmmaker is clearly hindered by the overall narrative arc (one of those origin-story prequels for which modern movie junkies have a peculiarly ravenous taste), his distinctive mark is evident in most of the other details. Dark forest inhabitants leap out at our heroes like Evil Dead beasties, and Raimi’s playful wit is evident in everything from a sharp-toothed river fairy with a penchant for spit-takes to a ragged yellow brick road directional sign that points to ‘China Town’ (a town made of… china). And it’s genuinely moving the way that he uses Oscar’s Edison hero worship to smuggle in a power-of-movies leitmotif very much reminiscent of Martin Scorsese’s Hugo. Though Oz has some of the same narrative issues and effects-heavy bloat as that highly personal fantasy film, every frame is infused with a deep-rooted, impassioned understanding of the cinema’s magical power to captivate and inspire. It’s nearly enough to counterbalance the movie’s many deficiencies; if only more similarly flawed pictures had this level of brains, heart and nerve.