Krasnodar: With only two days to go before Spain’s opening match at the World Cup, Julen Lopetegui was fired as national team coach because he accepted a job to lead Real Madrid next season.

Spanish football federation president Luis Rubiales, who made the announcement on Wednesday in Krasnodar, later said Fernando Hierro would replace Lopetegui as the coach for Spain’s match against Portugal in Sochi on Friday.

The 50-year-old Hierro, a former national team player and Real Madrid captain, had been acting as the federation’s sports director and was already in Russia with the national team.

Rubiales said firing Lopetegui wasn’t the best solution but it was needed after the federation was caught by surprise by Real Madrid’s announcement.

“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, who took over as president last month, said Lopetegui betrayed the federation’s values and it was the only decision he could make.

“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.”

Lopetegui did not attend the news conference but was expected to talk to the media later.

“We have to work on a series of decisions that come just two days before the opener,” Rubiales said. “There’s a lot to do.”