Rayo won 3-2 at sixth-placed Sociedad, Malaga won 2-0 at fellow strugglers Osasuna.
Rayo twice fell behind in San Sebastian - with local goals from Inigo Martinez and Ruben Pardo - but hit back with strikes from Joaquin Larrivey, Alberto Bueno and, finally, Ruben Rochina.
Rayo are still second from bottom, but are now level on 26 points with Almeria and Valladolid.
"They are a better team than us, without a doubt. But we played tonight without fear, knowing that only a win would be useful for us," said Rayo coach Paco Jemez.
Meanwhile, Sociedad's Pardo said: "We created good chances tonight but we missed most of them...We might still finish in fourth place, but we will need to be sharper in front of goal from now on." The defeat left Sociedad stuck in sixth place, one point behind fifth-placed Villarreal.
Earlier Monday, their 2-0 win at Osasuna lifted Malaga up to 13th.
Samuel Garcia gave the southerners the lead in the 16th minute by cleverly turning in a centre from left-winger Nordin Amrabat, who was the star of the show in Pamplona.
Malaga had right-back Jesus Gamez sent off six minutes into the second half for a second yellow card offence but bravely continued to come forward instead of sitting back.
Amrabat made it 2-0 in the 67th minute after playing a smart one-two with Roque Santa Cruz, and the visitors then had few problems in playing out time.
The win left Malaga level on 29 points with Elche and Osasuna - with all of them three points above the relegation zone.
Even so, Malaga coach Bernd Schuster was not sure about continuing in the job, saying: "This result does not change the situation very much. It doesn't really affect what might happen this week." Schuster has threatened to resign because of the abuse he has suffered recently from many Malaga fans.
Share
