Leganes were promoted to the top flight of Spanish football for the first time in their history after winning on the final day of the Segunda Division season on Saturday.
Pablo Insua scored with a header following a corner in the 48th minute to give Leganes a 1-0 win at Mirandes to clinch promotion to the Primera Division.
Leganes were only promoted to the second tier in 2014 and will now find themselves playing alongside the likes of Barcelona and Real Madrid next season.
They nearly were crowned Segunda Division champions as well, but already-promoted Alaves found a late equaliser through Manu Barreiro to draw 1-1 at Gimnastic and win the league by a single point.
Gimnastic finished third and will contest the playoffs with Girona, Cordoba and Osasuna.
Mallorca crucially won and Almeria earned a draw to stay up at the expense of Ponferradina, who were relegated along with Llagostera, Albacete and Athletic Bilbao B.