Former Champions League semi-finalists Villarreal have been promoted back to the top flight in Spain at the first time of asking after they beat promotion rivals Almeria 1-0.
The sides were level on points lying in second and third in the second division before kick-off,
Jonathan Pereira's goal was enough for Villarreal to take second spot and promotion behind champions Elche.
Almeria will now go into the play-offs.
The Andalusians will face Las Palmas in a two-legged tie with Girona playing Alcorcon in the other play-off semi-final.
Villarreal were relegated last season, and their campaign to come straight back up had suffered a tragic start, as new coach Manuel Preciado died from a heart attack on the very same day in June 2012 that he was appointed.
His successor, former B team coach Julio Velazquez, was sacked in January but coach Marcelino Garcia Toral has now finished the job.
The 'Yellow Submarine' were beaten in the 2006 Champions League semi-final by Arsenal.