Rayo Vallecano return to top flight
Oscar Trejo, Emiliano Armenteros and Nestor Susaeta scored the goals that set the party going at the Teresa Rivero stadium, to the south-east of Madrid's city centre.
Rayo are second in the standings, three points behind already-promoted leaders Real Betis, with two rounds of matches still to play.
Their promotion was achieved against a background of financial uncertainty with the owners being forced to apply to go into administration back in February, while players and staff continued working without getting paid.
The Ruiz-Mateos family sold their majority stakeholding to local businessman Raul Martin earlier this month.
Rayo become the fourth club from the Spanish capital in the top-flight along with Real Madrid, Atletico Madrid and Getafe, and they return after an absence of eight years.