Updated

Spain fired the men’s national soccer team manager Julen Lopetegui on Wednesday, just two days before the team’s opening World Cup match because he accepted a job to coach Real Madrid next season.

Assistant Fernando Hierro will replace Lopetegui as the squad gets ready to take on Portugal in its first Group B match of the tournament, Spanish soccer federal president Luis Rubiales announced.

Hierro was acting as the federation’s sports director and was already in Russia with the team before the announcement was made. Rubiales said the firing was needed because the federation was caught by surprise over Lopetegui’s decision to take over as Real Madrid’s coach.

WATCH LIVE 2018 FIFA WORLD CUP MATCHES STREAMING ON FOX SPORTS JUNE 14 TO JULY 15

“The federation cannot be left out of a negotiation by one of its workers and be informed five minutes before the press release,” Rubiales said. “We have been compelled to act.”

Rubiales accused Lopetgui of betraying the federation’s values.

“It's a difficult situation, but we are not the ones who determined the action that had to be taken. The federation has its values and it has to maintain them,” Rubiales said. “It may look like a weakness now, but with time this will make us stronger.”

Hierro was formerly a defender for Real Madrid and finished playing soccer with the English club Bolton in 2005. He played in four World Cups with Spain from 1990 to 2002.

Lopetgui’s decision to take the Real Madrid job with the World Cup just days away drew the ire of critics who quickly questioned his decision making when he announced the Spanish squad. Lopetgui chose six Real Madrid players to be on the squad over the likes of Barcelona’s Sergi Roberto and Chelsea’s Cesc Fabregas.

VIEW THE FULL 2018 FIFA WORLD CUP SCHEDULE HERE

“Wait, maybe I get a call up now!” Fabregas joked on Twitter soon after the announcement.

He followed it up by saying: “[It’s] a difficult situation in these moments for our squad but now more than ever is when we have to support them without stopping. I trust a lot in the talent and mentality of this team and I am sure that they can go far and fight for the title. Good luck, lads!”

Lopetgui took over the Spanish team after the 2016 European Championship that had been on the decline after its streak of winning the Euro in 2008 and 2012 and the 2010 World Cup.

The Real Madrid job was seen as one of the most coveted jobs since the sudden departure of Zinedine Zidane after winning the Champions League.

The Associated Press contributed to this report.