MADRID -- Rayo Vallecano earned promotion to Spain's top division after beating Lugo 1-0 on Sunday.
Alex Moreno's goal for the hosts in the 40th minute sealed Rayo's return to La Liga after two seasons in the Spanish second division.
Huesca had already secured promotion last weekend with a 2-0 victory at Lugo.
The third team to move up will be the winner of a two-round playoff between the four teams that finish the season from third to sixth.
Malaga, Las Palmas and Deportivo La Coruna were all relegated from the top flight this season.