Odriozola, 22, has won rave reviews for his displays with the San Sebastian club in La Liga.
His form on either side of defence even led to a surprise World Cup call-up for the full-back from former Roja coach Julen Lopetegui, although successor Fernando Hierro failed to give him a single minute on the field as Spain crashed out in the last 16.
Lopetegui has now made Odriozola his first major signing at Madrid, in a deal estimated to be worth the full value of Odriozola's €40 million (£35.4m/$46.8m) release clause.
The youngster, Madrid revealed, will also sign a contract until June 2024 at the Santiago Bernabeu once he has passed medical examinations.
"Real Madrid and Real Sociedad have agreed the transfer of Alvaro Odriozola, pending a medical," the Merengue confirmed via a statement released on the club's official website.
"The player will be tied to the club for the next six seasons."
La Real added in their own statement: "Real Sociedad want to thank Alvaro Odriozola for his professionalism and commitment shown to our club since his years as a youth player through to the first team, while also wishing him the best for his personal and professional future."
Odriozola is the first arrival in what promises to be a busy transfer window for Madrid, who were relatively inactive throughout Zinedine Zidane's two and a half years in the hotseat.
Cristiano Ronaldo has agreed to join Juventus in a sensational move, where he will take up the challenge of winning a league title in a third country after succeeding with Manchester United and Madrid.
PSG duo Kylian Mbappe and Neymar, meanwhile, have both been slated as possible replacements for the Portugal legend, although with both still active in the World Cup Blancos fans may have to wait for further transfer updates.