Real Madrid's late-season implosion continued with a humiliating 2-1 defeat at already relegated Murcia on Sunday, a game in which midfielder David Beckham was sent off for insulting a linesman.
Combined with Barcelona's 1-0 win at home to Racing Santander, the result handed the Catalans the advantage in the race to secure the runners-up spot behind Valencia and an automatic berth in the Champions League group phase.
With one game left champions Valencia top the table with an unassailable 77 points, Barcelona are second on 72, two ahead of Real and four in front of Deportivo Coruna.
Unless Real post a huge win in their final match of the season against Real Sociedad, Barca only need to draw their game at Real Zaragoza to ensure they finish second.
It is the first time in their 102-year history that Real have lost four league games in a row.
Athletic Bilbao clinched a UEFA Cup place with a 2-1 win at Osasuna, midfielder Francisco Yeste and Ismael Urzaiz grabbing their goals in the second half.
At the other end of the table, Barca's neighbours Espanyol spurned an opportunity to ensure their Spanish Primera Liga survival as they surrendered a two-goal lead to lose 4-2 at Real Mallorca.
LIFELINE
The result means Celta Vigo and Valladolid, who both lost on Saturday, have been thrown a lifeline and may yet avoid the drop if results go their way in the final round of matches next week.
Espanyol, though, can still make sure they stay up with a home win next week over Murcia, who prop up the table on 26 points despite their surprise win on Sunday.
Once again it was a former player who was responsible for Real Madrid's demise.
Murcia striker Luis Garcia, released by Real at the start of the season, got his side off to a dream start when he poked in from close range after visiting goalkeeper Iker Casillas spilled a shot from Richi in the third minute.
Real, who began knowing Barca had already won their match against Racing, looked flustered by the early setback and nearly conceded a second five minutes later but defender Ivan Helguera managed to scramble a goal-bound Richi shot off the line.
Murcia, who had won just four games all season and have the worst scoring record in the league, had several other good chances to extend their lead in the early minutes.
But Real, missing the suspended Ronaldo and Roberto Carlos, recovered their nerve and went on the attack, Beckham seeing a long-range effort tipped over by keeper Francisco Sanchez Broto and Raul sending a glancing header wide of the post soon after.
They looked certain to equalise midway through the half when Argentine midfielder Santiago Solari checked past two defenders and the keeper only to fire his shot on to the bar.
Just when it looked as if Murcia would fold under the pressure, they went 2-0 up after Helguera conceded a penalty when he handled as the ball spun off the foot of fellow defender Alvaro Mejia.
Garcia gave Casillas no chance as he blasted the spot kick high into the net and things went from bad to worse for Real as Beckham received his marching orders for shouting an insult to the linesman.
It was the England captain's second red card since joining Real and means he will end his first season at the club on a low note, missing the final game at home to Real Sociedad.
The visitors were unable to stage a recovery after the break and Murcia, coached by former Real boss John Toshack, comfortably preserved their advantage until substitute Guti cracked home a long-range shot in injury time.
More from rediff