The 22-year-old came through the youth system at Sociedad before making 50 La Liga appearances and earning a spot in Spain's squad for the World Cup.
Odriozola did not make an appearance in Russia but that has not prevented former national team coach Julen Lopetegui opting to take the right-back to the Bernabeu.
A club statement read: "Real Madrid and Real Sociedad have agreed the transfer of Alvaro Odriozola, pending a medical. The player will be tied to the club for the next six seasons."
Real - who will pay just over £35m - now have three designated right-backs on their books, with Odriozola joining both Dani Carvajal and Achraf Hakani.