Osasuna had lost their previous four league games to slide into the bottom three but they belied their position as Álvaro Cejudo claimed a deflected winner just before the hour to lift them above the drop zone.
Villarreal also fell behind in their game when Pedro Ríos struck for Getafe but they recovered to win thanks to goals from Cani and Giuseppe Rossi.
Getafe dropped into the bottom three as a result, but two other struggling sides boosted their survival odds with victories. Júlio Baptista scored twice, taking his tally to five in his last three games, as Málaga beat second-bottom Hércules 3-1, and Racing Santander beat Mallorca 2-0.
Lastly, Sevilla rose to fifth after Renato scored the only goal at ten-man Almería.