MADRID, May 16 (Reuters) - Real Madrid lost 4-3 at Sevilla but still finished second in the Primera Liga as Osasuna beat Valencia 2-1 to qualify for the Champions League for the first time in their last games of the season on Tuesday.
Goals from David Beckham put Real two up inside 26 minutes but UEFA Cup winners Sevilla stunned the visitors by scoring four times before the break to take control of the game.
Zinedine Zidane, in his last match as a Real player before retiring, pulled a goal back in the second half.
Real finished behind champions Barcelona with 70 points to earn a place in next season's Champions League group stage.
Valencia were third with 69 after Savo Milosevic and David Lopez scored for Osasuna, who came fourth with 68.
Valencia and Osasuna go into the third qualifying round of Europe's top club competition while Sevilla, who also had 68 points but an inferior head-to head record, had to settle for defending the UEFA Cup next season after finishing fifth.
Barca, who face Arsenal in the Champions League final on Wednesday, have 82 points before the last game of the Primera Liga season sees them visit Athletic Bilbao on Friday.
Real's game started at breakneck speed with Sevilla's Luis Fabiano hitting the post after a minute and Zidane crashing a spectacular volley against the bar soon after.
But the visitors showed greater urgency and took the lead in the 15th minute when Beckham's free kick drifted in as Julio Baptista went for a header and put off keeper Andres Palop.
The England midfielder doubled Real's advantage in the 26th minute, latching on to Roberto Carlos's long cross-field pass and slipping the ball under Palop.
The home side cut the deficit two minutes later when winger Jesus Navas let fly with a fierce 25-metre drive that flew into the top corner.
Navas was given room to cross from the right in the 30th minute and when Iker Casillas fumbled the ball Javier Saviola was on hand to thump the rebound high into the net.
Real's defence was ragged and three minutes later Fabiano controlled the ball in the area and picked out Saviola's near-post run, the Argentine scoring with a sharp shot.
A minute before the break Navas put Fabiano clear in the area and the Brazilian fired into the far corner.
Zidane pulled one back for Real after 72 minutes as Palop flapped at a corner, allowing the France midfielder to score from the loose ball.
In Pamplona Osasuna coach Javier Aguirre's last game at the club turned into a celebration when they scored twice in two minutes early in the second half.
Serbian striker Milosevic headed the first in the 48th minute before Lopez was on hand at the far post to collect Pierre Webo's flick and fire back across goal just inside the post.
Valencia's David Villa curled a free kick over the wall at the end, taking his tally for the season to 25 and becoming the Primera Liga's joint top scorer with Barcelona's Samuel Eto'o.