Real Madrid have chosen Julen Lopetegui to be their next manager, with the current head coach of the Spanish national side set to move to the Bernabéu after the World Cup.

Lopetegui, who has signed a three-year-deal at Real, has a long association with the club, though he made a single professional appearance as a player. The 51-year-old will now face the challenge of refreshing a side that have won the Champions League three times in a row and boasts some of the biggest talents – as well as egos – in world football.

Julen Lopetegui sacked by Spain on eve of World Cup – live! Read more

“Real Madrid announce that Julen Lopetegui will be the coach of the first team during the next three seasons,” the club said in a statement. “Julen Lopetegui will join the club after Spain’s participation in the World Cup, after two years leading the national team.”

With the World Cup two days away the news of Lopetegui’s appointment came somewhat out of the blue and the timing will be questioned in Spain. From Madrid’s point of view, however, it is likely to be seen as a sensible move after the sudden departure of Zinedine Zidane last month. Lopetegui’s association with Real goes back 30 years to when he was a youth team goalkeeper. He also worked for the club as a scout and as coach of the club’s B team, Castilla.

Perhaps just as importantly the Spaniard was available. It had been widely understood that the president of Real Madrid, Florentino Pérez, had made Tottenham’s Mauricio Pocchetino his first-choice candidate to replace Zidane. But the Argentinian had signed a contract extension at White Hart Lane the week before the Frenchman’s departure and attempts to negotiate with Spurs’ notoriously intractable chairman and chief executive, Daniel Levy, got nowhere.

Jürgen Klopp and Antonio Conte were also considered but proved too expensive. Lopetegui, meanwhile, extended his terms with the national side only recently but the compensation clause in his contract was an insubstantial €2m (£1.75m), which Real have paid.

Having taken over from Vicente del Bosque as national coach in 2016, following a disappointing European Championships, when they were knocked out by Italy in the round of 16, Spain have gone unbeaten in 20 matches. Lopetegui has revitalised their style and rejuvenated an ageing team. He will be expected to do the same at his new club where as many as five first-team players are no longer wanted by the club.

Lopetegui has a spine of Real Madrid players in his team, with a total of six in the World Cup squad, and has built a particularly strong relationship with the club and national captain, Sergio Ramos. It is understood that that Madrid consulted their Spanish internationals before making the appointment.

Lopetegui was on Madrid’s books as a player for six years, though he played for the first team once. He also played for Barcelona and has been on record singing the praises of Lionel Messi, which may not go down well with Madrid supporters.

The Fiver: sign up and get our daily football email.

As a manager, Lopetegui has coached at all levels of the Spanish national side, winning the Under-19 European Championship in 2013 and the Under-21 equivalent the following year. His one significant role in club management came at Porto in 2014 but it was not a success and Lopetegui was fired after less than two years in the job. He was then approached to become manager of Wolverhampton Wanderers, only for the Spanish FA to secure his services shortly before a move was completed.

Spain begin their World Cup on Friday with a much anticipated all-Iberian encounter with Portugal.