Julen Lopetegui has been sacked as Spain's national team coach on the eve of the World Cup, one day after he agreed to take over at Real Madrid after the tournament.

In a news conference at Spain's training base in Krasnodar, Russia, Spanish federation president Luis Rubiales said Lopetegui's fate was sealed just two days ahead of the team's World Cup opening game, as Rubiales could not accept an Royal Spanish Football Federation (RFEF) employee having negotiated his next job without informing his employers.

The RFEF announced afterward that Fernando Hierro will assume the role of coach for the tournament. Hierro, the national team's sporting director, told reporters that he would try to change as little as possible.

Rubiales, who was elected as RFEF chief last month, was in Moscow for the vote on the World Cup 2026 host country, but he flew back to Krasnodar on Tuesday for an emergency meeting with Lopetegui. The coach's decision was announced at a news conference thereafter.

"We have been obliged to fire the national coach," Rubiales said Wednesday. "We wish him the best, he has done an excellent job in getting us to the tournament. But the federation cannot be left outside the negotiation of one of its employees, and find out just five minutes before a public announcement. If anybody wants to talk to one of our employees, they have to speak to us, too. That is basic, as this is the team of all Spaniards. The national team is the most important we have; the World Cup is the biggest of all."

World Cup 2018 must-reads

- Make your picks with ESPN FC Match Predictor 2018!

- Welcome to the Alternative 2018 World Cup Fans' Guide

- ESPN FC's experts make their picks

- Marvel's amazing World Cup spoilers

- Revealed: World Cup 2018 Ultimate XI

- Fixtures, results and full coverage

- Team-by-team previews of all 32 nations

Lopetegui told reporters at the airport in Krasnodar on his way back to Madrid: "I am very sad, but I hope that we play a magnificent World Cup and we win. We have a magnificent team and I hope that we win the World Cup."

Hierro was a defender for Spain's national team and Real Madrid and will coach the team starting with Friday night's game against Portugal.

"What we will do is touch as little as possible the national camp," Rubiales said. "We are working on it. When we know, we will tell you. We are all affected by this, but we must think about the best for the federation and the team. All this is a big blow, but we are training again this afternoon, will stick together and move forward. The players are very focused, and they have told me they are fully committed, and will give 100 percent."

Lopetegui is a surprising choice to take over at Real Madrid but his work with the Spain national team on the foundation and fundamentals make him an intriguing choice at the Bernabeu. PIERRE-PHILIPPE MARCOU/AFP/Getty Images

Rubiales suggested he had taken the decision personally, as the behaviour of both Lopetegui and Real Madrid had not met the level expected of those involved in Spanish football.

"I took a plane, came back from Moscow, missed the vote on the next World Cup to be here," he said. "We had to react, I know that whatever I do, I will be criticised. I accept that. But the values of the federation come first. I am sure Julen would have preferred it another way, and we wish him the best. He is a top coach for me, which made the decision very difficult. To win is very important, to have the best coach very important, but above everything is acting in the right way. Maybe this is tough now, but in the end it will make us stronger."

Spain's players, led by national team and Madrid captain Sergio Ramos, were reportedly in favour of Lopetegui staying on for the tournament. Rubiales repeatedly dodged questions over whether he had taken their advice before making the decision to fire the coach.

"I've a very close relationship with the players, also with Julen," he said. "It has been a very difficult decision, the most difficult for me. I have spoken with the players, and I can guarantee they will do everything, along with the new coach, to take the team as far as possible [at this World Cup]."

Ramos later said on Twitter: "We are the national team, we represent the shield, the colors, the fans and a country. The responsibility and the obligation is with us. Yesterday, today and tomorrow: #Let'sGoSpain"

Reports in Spain said Lopetegui, a former Madrid and Barcelona goalkeeper whose representative Carlos Bucero works closely with Portuguese super-agent Jorge Mendes, will triple his salary with the move.