Spain manager Julen Lopetegui will take over as Real Madrid boss after the World Cup, the Primera Liga giants have announced.
The move comes as a surprise, with Lopetegui not featuring prominently among the host of managers linked with the role since the departure of Zinedine Zidane days after Madrid's 3-1 victory over Liverpool in the Uefa Champions League final.
Lopetegui, who has been in charge of the national team for the past two years, has agreed a three-year contract at the Bernabeu.
A club statement said: "Real Madrid CF announces that Julen Lopetegui will coach the first team for the next three seasons.
"Julen Lopetegui will join the club after the participation of the Spanish team in the World Cup, after two years leading the national team."
Former goalkeeper Lopetegui, 51, made a sole league appearance for Madrid as a player, and later turned out for rivals Barcelona a handful of times. He managed Madrid's feeder club Castilla in 2008/09 before taking charge of Spain's youth teams.
In May, he signed a two-year extension to remain as Spain manager until 2020 but the call of Madrid has proved stronger.
Zidane's shock departure came after he had guided Madrid to a third straight Champions League title.
But Madrid had finished a distant third as Barcelona took the honours in the Primera Liga, and Lopetegui will be charged with closing what was a 17-point gap.
Among his first tasks will be resolving the future of Gareth Bale, with the Wales forward unhappy with his limited playing time under Zidane and in a powerful position after scoring twice off the bench in the Champions League final.