Spain legend Fernando Hierro guided his team through the group stage but was powerless to stop them being dumped out of the tournament on penalties by hosts Russian Federation in the round of 16.
Luis Enrique has replaced Fernando Hierro, who stepped down as interim coach over the weekend.
Spain only won one game at the World Cup, against Iran, and drew their other two group matches vs. Portugal and Morocco.
His appointment was announced this afternoon at a press conference by president of the Spanish Football Federation, Luis Rubiales.
Lopetegui was dismissed it was announced that he would take over at Real Madrid after the tournament.
Federer, Williams progress in Wimbledon
Open runner-up was a quarter-finalist at Wimbledon in 2015 but has struggled to build on that in the last two years. Five of the top 10 women's seeds have now failed to go beyond the second round at Wimbledon .
Luis Enrique has been on a sabbatical since leaving Barcelona in May 2017 and was a reported target of Paris Saint-Germain and Chelsea in April.
Roberto Martinez, the former Wigan and Everton manager who has guided Belgium to the World Cup semi-finals, had also been linked with the job, as had Michel and Quique Sanchez Flores.
The 48-year-old has become La Roja's new coach following caretaker boss Fernando Hierro's decision to stand down from the position on the back of a disappointing World Cup.
Remembering a world before the World Cup started is proving very hard now that we're in this utopia of brilliant football and weather so incredible that even in Manchester I've forgotten what rain looks like.
But now Spain have turned to Luis Enrique to guide the national team ahead of the 2020 European Championship.