Lopetegui previously coached Madrid's feeder club Castilla in 2008/09 before taking charge of Spain's youth teams.
Real have announced that after the tournament he will take over at the Bernabeu, stepping into the role that Zidane Zidane vacated following his shock departure at the end of May - just days after guiding Real to a third consecutive Champions League title.
Before he took over as Spain boss, Lopetegui was Porto manager for two years.
However, Lopetegui's appointment is another surprise from Los Blancos, particularly as he only signed a new deal to remain in charge of Spain until 2020 in May, per BBC Sport.
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.
Lopetegui impressed in quickly blending together a new side which won nine of their 10 World Cup qualifiers and is among the favourites for this summer's finals in Russian Federation.
But following the conclusion of the tournament in Russian Federation, which La Roja are considered one of the favourites to win, Lopetegui will transition into the role at Santiago Bernabeu.
Lopetegui will have his work cut out at Real Madrid, where standards are high and patience tends to be short with managers unless they deliver instant success.
Spain coach Julen Lopetegui will take over as Real Madrid boss after the World Cup, the La Liga giants have announced.