'Julen Lopetegui will join the club after the participation of the Spanish team in the World Cup, after two years leading the national team'.
If Spain fail to impress at the World Cup, then Lopetegui will head to Real Madrid under a cloud that will make an already difficult job even harder.
Lopetegui is now preparing to lead Spain at the World Cup but the 51-year-old will depart his role as national team coach at the end of the tournament.
The announcement comes shortly after Lopetegui extended his contract as Spain coach until 2020 in a pre-World Cup boost for one of the tournament favourites.
Lopetegui has never lost a match as Spain coach since taking the reins in July 2016 in the wake of the European Championship, earning 14 wins with six draws for the second-longest unbeaten start by a coach in Spain's history.
The 51-year-old replaced Vicente del Bosque at the helm of La Roja after the defending champions' disastrous 2014 World Cup title defence.
The former goalkeeper made a sole league appearance for Madrid as a player and later turned out for rivals Barcelona.
The Champions League holders have been searching for a new head coach ever since Zinedine Zidane took the decision to step down after two-and-a-half trophy-laden years in charge earlier this month. Spain will face Iran and Morocco in Group B after the challenge of Cristiano Ronaldo's Portugal in their opener on Friday.