Real Madrid captured a record 30th Spanish League title on Sunday with a come-from-behind 3-1 win over Real Mallorca.
They finished equal on 76 points with bitter rivals Barcelona, who won 5-1 at bottom club Gimnastic Tarragona, but finished ahead of the Catalan club thanks to their better head-to-head record.
"To win we had to suffer. We always seem to have to suffer for our victories, but I'm very happy," said Real coach Fabio Capello.
The victory also sent David Beckham away to Los Angeles with a league championship medal although the former England skipper was substituted before the end of the game.
"It's here and it's very deserved. The people who deserve it most are those who believed in us through the bad times. It's a victory and title for a team that's united and together," said Real captain Raul Gonzalez.
Real went unbeaten over their last 12 games of the season and, after lying third in mid-March, they clawed back a five-point advantage from both Barcelona and Sevilla.
They only needed to beat Mallorca to claim La Liga but the visitors' Fernando Varela silenced the 76,000 Real fans in the Santiago Bernabeu - which included film star Tom Cruise and his wife Katie Holmes - when he found the net after 17 minutes.
A defensive lack of concentration saw Juan Arango go around Sergio Ramos, and Michel Salgado failed to cut out the Venezuelan's cross, before Varela sloted the ball past Iker Casillas.
Madrid pressed hard and both Raul and Robinho went close but Real suffered another blow when Ruud van Nistelrooy, scorer of 26 goals this season, had to be taken off with a hamstring injury after 30 minutes.
Van Nistelrooy's departure meant he will only get a share of the European Golden Boot award with Roma's Francesco Totti.
Varela almost got a second goal after 55 minutes but, with only Casillas to beat, pushed the ball wide.
Beckham's four-year career at the Spanish club ended 65 minutes into his last game when he limped off, clearly still feeling the effects of the ankle injury he sustained during England's 3-0 win over Estonia 10 days ago.
He sat glumly in the dugout, under the gaze of his pop star wife Victoria who was sitting alongside Cruise, but his initial disappointment turned to joy as his replacement Jose Antonio Reyes found the net twice.
After only being on the field for three minutes, Reyes side-footed the ball past Mallorca goalkeeper Miguel Angel Moya after Gonzalo Higuain, Van Nistelrooy's replacement, had pulled the ball back from the dead ball line.
Nine minutes from time, Real finally got their noses in front when the ball glanced off an unlucky Angelos Bassinas after Moya had pushed a Mahamadou Diarra header onto his team mate.
Reyes then crowned Madrid's night to remember with a tremendous left foot shot two minutes later.
"There have been a lot of bad times this season but where you finish is more important than how you got there," said Reyes.
Barcelona completed their part of the bargain hoping that Real would slip up.
Carlos Puyol opened the scoring with a left foot shot from the edge of the six yard box, with the Barca captain hammering home a Lionel Messi pass after 20 minutes.
Messi then added a second after 35 minutes with an exquisite chip from just inside the area.
Ronaldinho made it 3-0 from a direct free kick three minutes later and Messi then got his second of the night five minutes after the break.
Swedish striker Tobais Grahn got a late consolation goal for Gimnastic late in the game before Barca's Gianluca Zambrotta ended their scoring spree in injury time.
Sevilla started the night in third place, two points in arrears of the leading two, but went down 1-0 at home to Villarreal, who secured fifth place.
Fabricio Fuentes header after 50 minutes provided Villarreal with their eighth consecutive win and a place in the UEFA Cup next season.
Real Zaragoza finished sixth and secured the other slot in the UEFA Cup.
Spanish football league table after Sunday's matches on the final day of the 2006-2007 season (played, won, drawn, lost, goals for, goals against, points):
Real Madrid 38 23 7 8 66 40 76
Barcelona 38 22 10 6 78 33 76
Sevilla 38 21 8 8 64 34 71
Valencia 38 20 6 12 57 42 66
Villarreal 38 18 8 12 48 44 62
Real Zaragoza 38 16 12 10 55 43 60
Atletico Madrid 38 17 9 12 46 39 60
Recreativo Huelva 38 15 9 14 54 52 54
Getafe 38 14 10 14 39 33 52
Racing Santander 38 12 14 12 42 48 50
Espanyol 38 12 13 13 46 53 49
Real Mallorca 38 14 7 17 41 47 49
Deportivo La Coruna 38 12 11 15 32 45 47
Osasuna 38 13 7 18 51 49 46
Levante 38 10 12 16 37 53 42
Real Betis 38 8 16 14 36 49 40
Athletic Bilbao 38 10 10 18 44 62 40
Celta Vigo 38 10 9 19 40 59 39
Real Sociedad 38 8 11 19 32 47 35
Gimnastic Tarragona 38 7 7 24 34 69 28
Champions: Real Madrid
Champions League: Barcelona, Sevilla, Valencia
UEFA Cup: Real Zaragoza, Villarreal
Relegated: Celta Vigo, Real Sociedad and Gimnastic Tarragona.