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
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."
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.