After thousands of actors were considered to portray a younger Han Solo for a “Star Wars” spinoff, Alden Ehrenreich has landed the coveted role.

Hollywood sources tell us Ehrenreich has signed on to play the iconic role, made famous by Harrison Ford, in the new movie, slated for 2018, which will focus on Solo before he joined the Rebel Alliance.

One insider told us of Ehrenreich, 26, who most recently appeared in “Hail, Caesar!”: “Alden really impressed Disney and Lucasfilm execs with his screen tests. The deal is basically done.”

Relatively little-known Ehrenreich — who’s also the lead in Warren Beatty’s upcoming, untitled Howard Hughes project with Fox — beat out candidates including “Divergent” stars Miles Teller and Ansel Elgort, Scott Eastwood, “Kingsman” and “Eddie the Eagle” star Taron Egerton, and “Sing Street” star Jack Reynor.

The casting of the Han Solo character has been so shrouded in secrecy it was named “Project Red Cup,” in reference to the ubiquitous red plastic Solo cups.

Lawrence Kasdan — who co-wrote “The Empire Strikes Back,” “Return of the Jedi” and “The Force Awakens” — said in a recent Q&A that the spinoff would not delve into the origins of Solo: “It will not be, ‘Here’s where he was born and this is how he was raised.’ I think what it will be is, ‘What was he like 10 years earlier?’ . . . But [legendary Japanese filmmaker Akira] Kurosawa once said the heroes are the ones that are still changing and the villains are locked and petrified into what they are.”

The film won’t start shooting until January, but reports are that the early casting is because the new Solo will have a cameo in “Rogue One: A Star Wars Story,” which is now shooting. That film is said to be set between “Episode III” and “Episode IV.”

Ehrenreich’s publicist Nicole Caruso at Irrelevant PR didn’t get back to us.