Cordoba sealed a sensational return to La Liga for the first time in 42 years as chaotic scenes marred their 1-1 draw with Las Palmas.
Las Palmas found themselves 1-0 ahead and on course to clinch promotion as Sunday's Segunda Division play-off final second leg entered injury time, only for premature pitch invasions from fans to spark a dramatic end to the match.
The game was stopped by the referee to allow order to be restored and, when play eventually restarted 10 minutes later, Cordoba sensationally scored a last-minute equaliser to secure victory on away goals as the tie ended 1-1.
Midfielder Apono earlier broke the deadlock in the 48th minute, but Uli Davila netted the crucial goal that saw Cordoba promoted the top flight for the first time since 1972.
Sections of the home support returned to the pitch as Davila's close-range effort for the visitors hit the back of the net, causing the final whistle to be blown.
Managers and players rushed for safety as more fans rushed the pitch and celebrations were restricted to the dressing rooms, while home supporters clashed with each other for causing the earlier delays.
Cordoba coach Albert Ferrer will now prepare for trips to former club Barcelona, Real Madrid and champions Atletico Madrid alongside fellow promoted sides Eibar and Deportivo La Coruna.