The short statement also added that the Basque will take up his role after the World Cup, which starts on Thursday and finishes on July 15, with Spain among the favourites to reach the final in Moscow.
"It's a similar situation here; he already had the contract signed with the Spain national team for two more years, but Real Madrid, who couldn't get Mauricio Pochettino, made a decision to go for him, and two days before the beginning of the World Cup they announce it".
Zidane's resignation came as a big shock, as he had just led Real Madrid to a third consecutive UEFA Champions League triumph. And as they had hoped, the European champions have announced the Frenchman's successor ahead of this summer's World Cup.
Will take over after managing Spain in the World Cup. He replaces Zinedine Zidane, who shockingly and abruptly left the club on the final day of last month.
Springboks Schalk Brits recalled England Test Bloemfontein
The Springbok team to face England in the second Test in Bloemfontein's Toyota Stadium will be named on Thursday. "So hopefully we can build on why the first 20 minutes that was so good".
It remains to be seen if he will head to Real as a World Cup victor, though Spain's squad is stocked with exciting talent.
Before he took over as Spain boss, Lopetegui was Porto manager for two years.
The appointment of Lopetegui could lead to a thawing in the relationship between Ronaldo and Real Madrid who are now refusing to give the 33-year-old the new contract he wants. Lopetegui spent part of his footballing career at Real Madrid, but only managed one senior appearance for the club.
Lopetegui has put together a record of 14 wins and six draws from his 20 games in charge of Spain, with the former goalkeeper having previously coached at Under-19, Under-20 and Under-21 levels.