In “Hugo,’’ an exhilarating tale of magic, machines, memories, and dreams, Martin Scorsese pulls off the neatest trick of all. He marshals the marvels of modern movie technology - up to and including the dreaded 3-D - to create a love letter to the earliest of movies and, by extension, to every movie from then to now. Yes, “Hugo’’ is a family film and, yes, your children and your inner child stand to be enraptured, but the family Scorsese really made this for is the 100-year-old tribe of watchers in the dark.

“Hugo’’ is based on Brian Selznick’s 2007 young-adult novel “The Invention of Hugo Cabret,’’ an extraordinary work of imagination. Half prose, half gorgeously detailed pencil drawings, it tells the tale of an orphaned boy hiding in the walls of a Paris railway station in the late 1920s, winding its many clocks, as his late father and drunken uncle have instructed him. A broken mechanical man his father rescued from a museum leads Hugo to the aged proprietor of the station’s toy stall and to secrets the old man would prefer to forget.

Scorsese, screenwriter John Logan, and an army of sympathetic technicians bring the book off the page and into the realm of digitally amplified movie reality. The train station is a breathing, hyperrealistic world unto itself, the many passengers rushing through and never noticing the society that roots there: the pretty florist (Emily Mortimer) and wise bookseller (Christopher Lee), the officious station inspector (Sacha Baron Cohen) with his bright-blue uniform and creaking leg brace.

Hugo (Asa Butterfield) is the ghost in this machine, popping out to swipe a brioche and ducking back in to wind the gears and keep the trains on time.

Get The Weekender in your inbox:

The Globe's top picks for what to see and do each weekend, in Boston and beyond.

All he has left of his father (a briefly seen Jude Law) is the mysterious automaton, and the cantankerous toy-seller Papa George (Ben Kingsley) threatens that. But Papa George has a young adopted daughter named Isabelle (Chloë Grace Moretz) who decides to help Hugo out - she reads books and is craving her own adventure - and the two begin connecting the dots that lead to Papa George’s past.

More coverage

It’s a real past, involving real films from the first days of the cinema, as well as the first special effects, handmade and sublime. But “Hugo’’ works as an emotionally loaded story on its own, with or without the history lesson. Butterfield is blessedly noncute in the lead, burning with ideas and always on the edge of despair, and Moretz, last seen playing a middle-school assassin in “Kick-Ass’’ and a vampire in “Let Me In,’’ rises to the occasion and gives us a normal, ardent, book-loving kid. And there’s Kingsley with his oddball line-readings that cut right to the heart of the matter and, late in the film, a few scenes by Helen McCrory as Papa George’s wife that floor you with their compassion.

Scorsese plunks these actors into his half-real, half-digital Paris with confidence and wit. No one may have used 3-D this wryly before: A close-up of Baron Cohen, leaning into the frame until his nose is practically in your popcorn may, in and of itself, justify the technology. The director knows how to give the kids a giggle, too, with a few doggie reaction shots that the extra dimension, for once, renders genuinely funny. (That said, the movie may be too unsettlingly rich and moody for the youngest audiences.)

The 3-D and digital gimcrackery and camera angles that defy the laws of physics would be nothing if “Hugo’’ weren’t rooted in a love of storytelling and the visual medium that has carried it forward for a century. At one point, when Hugo and Isabelle are finally learning about Papa George’s legacy, the screen explodes with images from the movies’ birth: trains pulling into stations (and panicking the audience), a kiss in close-up, a cowboy shooting into the camera, a rocket landing in the face of a grimacing moon.

It’s a testament to the possibilities of pictures moving on a wall, and it comes to us as that possibility is close to being extinguished by onrushing waves of technology. “Hugo’’ is a grand farewell and a stunning reintroduction, cued to a line of dialogue that’s nearly a throwaway. After Hugo has taken Isabelle to a screening of the Harold Lloyd comedy classic “Safety Last,’’ she tells him, simply: “Thank you for the movie. It was a gift.’’ “Hugo’’ is Scorsese’s gift to all the dreamers who were and all the dreamers still to come.

BostonGlobe.com complimentary digital access has been provided to you, without a subscription, for free starting today and ending in 14 days. After the free trial period, your free BostonGlobe.com digital access will stop immediately unless you sign up for BostonGlobe.com digital subscription. Current print and digital subscribers are not eligible for the free trial.

Thanks & Welcome to Globe.com

You now have unlimited access for the next two weeks.

BostonGlobe.com complimentary digital access has been provided to you, without a subscription, for free starting today and ending in 14 days. After the free trial period, your free BostonGlobe.com digital access will stop immediately unless you sign up for BostonGlobe.com digital subscription. Current print and digital subscribers are not eligible for the free trial.