If Spain fail to impress at the World Cup, then Lopetegui will head to Real Madrid under a cloud that will make an already difficult job even harder.
Lopetegui will put to pen to paper on a three-year deal at the Bernabéu running until 2021, the club confirmed.
Lopetegui took over Spain in July 2016 after Vicente del Bosque retired from the role.
But with three days before Spain's World Cup opener against Portugal in Sochi, Madrid announced that the Basque tactician will leave that position after agreeing a three-year contract with the La Liga giants.
Rohr speaks on players' fitness ahead of Nigeria, Croatia match
Recently, the Official World Cup song, titled "Live It Up" by Will Smith, was released on different Music streaming platforms. Nigeria have already gone and wrapped up this World Cup on style points, and at an absolute canter.
The Red Arrows wish England luck ahead of World Cup
Harry Kane says England will be "aggressive and brave" during this summer's World Cup in Russian Federation . We are our own team, we have our own identity and we just have to look forward and enjoy it.
Bound flight from Rome diverted over "potential security concern"
United said in a statement that the landing was due to "a potential security concern" but declined to comment further. Passengers are now being investigated with police taking writing samples from all those on board.
Previously, French manager Zinidine Zidane shocked the footballing world by announcing his resignation from Real Madrid. Before that, he was in charge of Spain's U21s, who won the 2013 European Championships.
Lopetegui, 51, was hired by Spain following their underwhelming Euro 2016 campaign and the former Porto boss has helped re-establish La Roja as genuine contenders this summer in Russian Federation.
The former goalkeeper made a sole league appearance for Madrid as a player and later turned out for rivals Barcelona.
He began coaching in 2003 as assistant manager to Spain's Under-17 team and was also in charge of the Under-19s, Under-20s and Under-21s, before moving to Porto.
Lopetegui's side qualified for the World Cup by topping their group with nine wins out of 10.