Lopetegui was announced as Zinedine Zidane's successor in a move that surprised many just days before the World Cup in Russia is due to start.
The announcement initially claimed that the 51-year-old would take the reins at Santiago Bernabeu after the conclusion of the tournament, but La Roja have acted now after making the announcement at a press conference in Krasnodar.
"We have decided to fire the national coach," Spanish Football Federation president, Luis Rubiales, said. "What we have achieved in getting here is due in great part to him, and we must thank him and wish him luck."
Rubiales insists he does not feel undermined, but has suggested that Real acted in a manner unbecoming of their status.
He added: “I don’t feel betrayed. Lopetegui has done impeccable work. How all this has been done is something else.
"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.
"Real Madrid look for the best coach, that is fine by me. I have no opinion about how Real Madrid act. But the federation have an obligation to represent all Spaniards.
"I found out [about the deal with Madrid] five minutes beforehand and asked for nothing to be done, that I was getting a plane and coming here.
"But, after five minutes, I saw it in the press and we had to react. We have a responsibility. I know there will be criticism but the values of the RFEF are set by the RFEF itself.
"To win is very important, to have the best coach is 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.”
Lopetegui was unbeaten in his time in the Spain dugout, guiding his team to 14 wins and six draws from 20 matches, and he signed a new two-year contract to take him through to Euro 2020 in May.
The stunning development threatens to destabilise a team regarded as one of the favourites to win the tournament in Russia.
Rubiales has not revealed who will be in charge for La Roja's opening game of the tournament, but insists that an announcement will be made in due course.
“We are going to touch as little as possible," he said. "We are working on it. When we know we will tell you.”
Spain sporting director Fernando Hierro and Under-21 coach Albert Celades have been tipped to take over for at least the World Cup.
The planned media conference on Wednesday was delayed by more than an hour while Rubiales reportedly held last-minute talks with Lopetegui.
There were also rumours the team's senior players, including captain Sergio Ramos, had called for the former Porto coach to stay in charge for the tournament.
Rubiales, though, insists the squad is entirely focused on Friday's match against Portugal in Sochi.
"All this is a big blow, but we are training again later today, we will stay together and move forward," he said.
"The players are very focused and they have told me they are fully committed and will give 100 per cent."