The Serie A champions will pay 20million euros (£15.8m) for Morata, who has signed a five-year contract.
A statement on the Juventus website confirmed the deal and revealed Real have an option to buy back the player in the summers of 2016 or 2017 for a fee of up to 30m euros.
Morata is a Spain Under-21 international and was part of Carlo Ancelotti's first-team squad last season, winning a Champions League medal, but he started just three league games.
"Juve are one of the best clubs in the world, and the best in Italy," Morata said through Juventus' official Twitter account. "I am keen to contribute to the pursuit of further success.
"I've spoken to Allegri and I have a strong desire to get to work.
"I've wanted to play for Juve for a long time and the club have always shown a strong interest in me.
"I feel ready. I know it will be hard, but I'm ready to tackle Serie A head on."
Arsenal and Wolfsburg were among the other clubs linked with the 21-year-old.
Real, meanwhile, have loaned Brazilian midfielder Casemiro to Porto for the forthcoming season.
The Portuguese club will have the chance to make the deal permanent next summer.