Sevilla, who finished sixth in La Liga this season, said in a statement on their website that the 52-year-old would lead their team for the next three seasons.
He replaces Joaquin Caparros who had been in charge of the side on an interim basis since March and is Sevilla's sixth coach since Unai Emery left the club three years ago.
Lopetegui, appointed by Spain after Euro 2016 and unbeaten in his 20 games in charge, was sensationally fired two days before last year's World Cup for failing to tell his federation that he had agreed to coach Real Madrid after the tournament.
That threw Spain's preparations into chaos and they were eliminated in the round of 16 by hosts Russia after the federation rushed to replace him with Fernando Hierro.
The move to Madrid also turned sour as Lopetegui was sacked only three months into the season, the final straw being a 5-1 defeat to arch-rivals Barcelona.
Of his 10 La Liga games, Lopetegui won four, drew two and lost four, leaving Real floundering in ninth place in the table.
His first coaching job was with Rayo Vallecano in Spain's second tier in 2003 where he left after only 10 matches.
He had several years coaching Spain's youth teams before being appointed by Porto in 2014. Although he led them to the Champions League quarter-finals in his first season, they failed to win the Portuguese league and he eventually left the club after 18 months.
Six months later, he was named by Spain to replace Vicente del Bosque..
(Writing by Brian Homewood; Editing by Christian Radnedge and Mark Potter)