Sporting Gijon came back from a goal down to beat Recreativo Huelva 2-1 on Sunday evening and secure Primera Liga survival on a dramatic last day of domestic action.
Sporting were in charge of their own destiny and therefore knew a win at home to already-relegated Recreativo would be enough to prolong their stay in the top-flight to a second year.
But the Andalusians were in no mood to lie down and took the lead through Ersen Martin halfway through the first half.
Sporting came back, though, and second half strikes from David Barral and Luis Moran ensured survival for the Asturians as Real Betis surprisingly dropped to the second tier.
Sporting began the day level on points with 18th-placed Osasuna, but sat above the Pamplona-based side thanks to their superior head-to-head record.
As well as those two sides, Betis, Getafe and Valladolid were also in danger of going down.
Osasuna, on 40 points at the start of the day, were at home to Real Madrid, while Getafe, on 41, travelled to Racing Santander and Betis, also on 41, hosted Valladolid, on 42.
But Sporting knew they needed to worry little about what was going in those matches, provided they kept their side of the deal and beat Recre.
And they should have taken the lead after just nine minutes when Diego Castro found himself one-on-one with Asier Riesgo, but the Recre keeper stood tall and made a fine save.
Sporting were enjoying the majority of the possession early on, but the home side were stunned after 23 minutes when Recre took the lead against the run of play.
Turkey striker Martin received the ball on the edge of the box and lashed an unstoppable drive past Ivan Cuellar to silence the crowd at El Molinon.
With Osasuna drawing 1-1 with Madrid at this stage, Sporting would be the team to go down.
But there was still a long way to go.
And Sporting piled on the pressure before half-time.
Barral's fierce drive was well saved by Riesgo after 35 minutes later and Kike Mateo headed wastefully over the bar in the home side's next attack.
After the break, Sporting continued to lay siege on the Recre goal, but they were up against an inspired Riesgo.
The Basque keeper made two brilliant saves to deny Kike Mateo and also did well to keep out a Diego Castro piledriver as Sporting pressed for a breakthrough.
They eventually got it after 58 minutes as this time Riesgo could do nothing to prevent Barral's low drive from finding its way into the bottom corner.
But two minutes later, Osasuna went 2-1 up against Madrid and that meant Sporting now needed a win to stay up.
Luckily for them and the nerves of their anxious fans, the second goal arrived quickly.
This time, the hero was Moran, who beat Poli and lashed a powerful angled drive into the corner to send the home fans into jubilation.
Sporting did have one scare in the closing stages, when Martin crashed a header just past the post for Recre.
They held on, though, and can now start planning for their second successive season of top-flight football.
They finished 14th with 43 points, 10 more than Recre, who ended bottom.