Former goalkeeper for Barcelona and Spain, Julen Lopetegui
CNN  — 

Less than 24 hours after the unexpected announcement that Spain manager Julen Lopetegui would take over at Real Madrid next season, the Spaniard has been sacked by the country’s football federation.

Lopetegui’s dismissal comes just two days before Spain’s opening World Cup game against Euro 2016 winners Portugal on Friday.

“We have been forced to make this decision,” Spanish Football Association President, Luis Rubiales said according to a series of tweets from the official Royal Spanish Football Federation’s official twitter account (RFEF).

Former Spain and Real Madrid captain Fernando Hierro, who was part of four Spanish World Cup squads between 1990 and 2002, will lead the team through the tournament.

“RFEF cannot be sitting on the sidelines whilst someone negotiates with one of its employees and then find out five minutes later before the news is made public,” added Rubiales.

“It’s a difficult and painful situation, and we would have liked for it to have finished differently with Julen. But we didn’t plan the way it played out.

“We are all affected by this, but we have to think about what is best for the whole of RFEF and the national team.

“I’m sure in time, we will be stronger for this decision. We wish him the best of luck.”

INTERACTIVE: World Cup in numbers

READ: The secrets to Germany’s World Cup success
READ: World Cup 2026: US-Mexico-Canada bid chosen as host

On Tuesday, it had been announced that former goalkeeper Lopetegui would join Real, who last month won the Champions League for the third year in a row, following the resignation of Zinedine Zidane at the end of May.

Lopetegui took charge of Spain in July 2016, leading the 2010 World Cup winners to nine wins and one draw in a qualifying group that included four-time winners Italy.

CNN’s Patrick Sung Cuadrado contributed to this report