“Hugo,” an enchantment from Martin Scorsese, is the 3-D children’s movie that you might expect from the director of “Raging Bull” and “Goodfellas.” It’s serious, beautiful, wise to the absurdity of life and in the embrace of a piercing longing. No one gets clubbed to death, but shadows loom, and a ferocious Doberman nearly lands in your lap. The movie is based on the book “The Invention of Hugo Cabret,” but is also very much an expression of the filmmaker’s movie love. Surely the name of its author, Brian Selznick, caught his eye: Mr. Selznick is related to David O. Selznick, the producer of “Gone With the Wind” — kismet for a cinematic inventor like Mr. Scorsese.

Mr. Scorsese’s fidelity to Mr. Selznick’s original story is very nearly complete, though this is also, emphatically, his own work. Gracefully adapted by John Logan, the movie involves a lonely, melancholic orphan, Hugo (Asa Butterfield), who in the early 1930s tends all the clocks in a Parisian train station. Seemingly abandoned by his uncle, the station’s official timekeeper (Ray Winstone), Hugo lives alone, deep in the station’s interior, in a dark, dusty, secret apartment that was built for employees. There, amid clocks, gears, pulleys, jars and purloined toys, he putters and sleeps and naturally dreams, mostly of fixing a delicate automaton that his dead father, a clockmaker (Jude Law), found once upon a time. The automaton is all that remains of a happy past.

Hugo has been repairing the automaton with mechanical parts salvaged from the toys he has stolen from a toy store in the station. All that he needs now to bring the windup figure to life — it sits frozen, with a pen at the ready, as if waiting for inspiration — is the key that will open its heart-shaped lock. After assorted stops and starts and quick getaways, Hugo finds the key during an adventure involving the toy-store owner and his goddaughter, Isabelle (Chloë Grace Moretz). A beloved, wanted child, she brings Hugo into her life, which is how he discovers that the cantankerous shopkeeper with the white goatee and sad, watchful eyes is Georges Méliès (a touching Ben Kingsley).

The name means nothing to Hugo and may not mean much to most contemporary viewers, but it means a great deal to this lovely movie. A magician turned moving-picture pioneer, Méliès (1861-1938) began his new career after seeing one of the first public film projections in Paris on Dec. 28, 1895. Until then, early moving pictures had been commercially exhibited on Kinetoscopes, peephole machines that enabled viewers to watch brief films, one person at a time. The image was tiny — less than two inches wide — and moving pictures didn’t become cinema as we know it until wizards like the French brothers Auguste and Louis Lumière created machines like the cinématographe, which projected larger-than-life images on screens that people watched as an audience.