It took more than half a century, but Jack Kerouac’s autobiographical cult novel of bohemian youth in postwar America has reached the screen in wonderful form.

Brazilian director Walter Salles and Puerto Rican screenwriter Jose Rivera, the team behind 2004’s brilliant road movie “The Motorcycle Diaries,” build a lyrical mood here. Their film is faithful to the spirit of Kerouac’s phantasmagoric prose, creating an elegy to the Eisenhower-era rebels who rejected smothering conformity to seek elusive transcendent truth and freedom.

From the idyll’s exhilarating start to its lamentable dead end, the film carries us along for an unforgettable ride. Kerouac’s hallmark is an elliptical storytelling style requiring an active audience. Salles’ film, while not quite a puzzle, is full of gaps and undercurrents. Like the source novel, it rambles but is never incoherent.

Salles trusts the audience to put everything together, just as the story’s characters must do. At the center of the swirl is narrator and Kerouac stand-in Sal Paradise (English actor Sam Riley). Sal is a would-be writer living with his mother, seeking a father figure, and under the sway of his disreputable new friend Dean Moriarty (Garrett Hedlund) based on notorious free spirit Neal Cassady. Sal is fascinated by the charismatic, garrulous roustabout, who seems to know every key member of the Beat Generation, and every backwoods gas station with an unguarded food shelf and fuel pump.

Sal becomes Dean’s literary tutor while Dean introduces shy Sal to sex, drugs and bebop. Sal recognizes that his slippery friend’s a “con man” while overestimating how long that character trait might remain entertaining. They fly across the nation’s back roads like visionary nomads, with Dean’s impulsive energy counterbalancing Sal’s need to withdraw and observe.

Dean treats the women in his life poorly, bouncing between his neglected wife, Camille (Kirsten Dunst), and his brazen teenage lover, Marylou (Kristen Stewart), reflecting the second-class status of women even among the era’s counterculture. A creature of untrammeled libido, Dean also makes time for lovestruck poet Carlo Marx (Tom Sturridge, playing the fictional version of Allen Ginsberg) and an occasional male trick. Their travels bring them into contact with plenty of squares and drug-addled mentor Old Bull Lee (Viggo Mortensen, doing a wicked impression of the mad novelist William S. Burroughs).

Eric Gautier’s camerawork captures the film’s smoky interiors and wide open spaces with hallucinogenic beauty. The film vividly renders jazz-club hedonism and the eventual hangovers. When Sal and Dean come to their inevitable parting on the streets of Manhattan, the scene is genuinely painful. Sal, who has written a novel based on the experiences Dean provided, is smartly dressed and off to see Duke Ellington with some upstanding new friends. Dean, shivering and shabby, approaches from the shadows to say hello, but is rebuffed like a panhandler. The brilliance of Riley’s and Hedlund’s performances is that the amount of pain in each actor’s eyes is about the same.

There’s probably no substitute for reading “On the Road’s” incandescent prose. But this filmed interpretation is a very fine version all on its own.