The search to replace Zinedine Zidane, who left after guiding Real to a third-straight Champions League title, lasted nearly two weeks, with Mauricio Pochettino, Antonio Conte and Jurgen Klopp among the names reportedly in the frame.
Lopetegui, who has coached the Spanish national team for the past two seasons, will coach Real for the next three seasons, the statement added.
Lopetegui will put to pen to paper on a three-year deal at the Bernabéu running until 2021, the club confirmed.
Real had been heavily linked with a number of potential managerial appointments following the shock resignation of Zinedine Zidane, including Tottenham boss Mauricio Pochettino and former Spurs and Porto manager Andre Villas-Boas.
He is said to have signed a three-year contract with the Los Blancos.
Lopetegui, 51, has been in charge of the Spanish national team since July 2016, when he took the reins following the European Championship in France.
He also played for both Real Madrid and Barcelona, although he only played one league game for Madrid, and five for Barcelona.
After retiring from football, Lopetegui became an assistant for Spain's U17 team in 2003, before swiftly taking charge of Liga B side Rayo Vallecano.
Lopetegui's side qualified for the World Cup by topping their group with nine wins out of 10.