Real Madrid kept an A-list of Hollywood celebrities glued to the edge of their seats to the finish.
Real Madrid rallied for a 3-1 victory over Mallorca and claimed a record 30th Spanish league title - edging two-time defending champion FC Barcelona on head-to-head results and making the Catalan club's 5-1 win over Gimnastic Tarragona inconsequential.
David Beckham's exit wasn't as dramatic as his replacement. Jose Antonio Reyes came in for the departing English midfielder in the 66th minute, scoring the equalizer a minute later and adding the finale in the 83rd as Madrid ended a four-year major trophy drought.
Midfielder Mahamadou Diarra, who received special permission from FIFA to miss Mali's African Cup of Nations qualifier on Saturday to play, headed in the winner in the 80th.
Beckham, who will now join Major League Soccer's Los Angeles Galaxy, showed his trademark free kicks still had their bite with the England midifielder coming close to scoring on a number of chances.
But in the end, the 32-year-old Englishman nibbled on his shoe nervously after being replaced while wife Victoria and friends Tom Cruise and Katie Holmes - as well as French Open champion Rafael Nadal - watched from the stands as Madrid rallied again.
"This championship is not so much a difficult one, it was almost miraculous one because we came from so far behind Barcelona to win," Capello said. "We suffered and fought to recover the spirit of this team. Tonight, we saw this."
Barcelona could only watch from the Nou Estadi stadium as Madrid ended its hopes of a third straight league title. "We were inconsistent all season ... and we're all aware that it's the players who are responsible," Barcelona captain Carles Puyol said. "I've always said that who wins this league deserves it."
Lionel Messi scored two goals and set up Puyol for another. Ronaldinho curled in a free kick for his 21st goal of the season before Gianluca Zambrotta scored in injury time as Barcelona finished without a trophy for the first time in three seasons.
Madrid ended its longest major trophy drought in 53 years with wild celebrations and a lap of honor before throwing coach Fabio Capello into the air as the Italian won his second title as coach at Madrid. The other was in 1997.
As the Madrid players names were read aloud, Beckham walked on to a loud ovation with his three children before kissing the center circle.
The team traveled to the Plaza de Cibeles in the city center as is customary in an open-top bus to celebrate with thousands of cheering fans. The players waived flags and drank champagne while fireworks splashed across the sky.
"This was a strong team with a lot of heart," said league scoring leader Ruud van Nistelrooy, who was replaced in the 33rd because of a left leg injury. "We won this league with our play over the last 10 games. It was difficult with all the pressure but now ... we are champions and this is the most memorable year of my career."
Also, Villarreal clinched a UEFA Cup place and knocked Sevilla out of contention for its first league title since 1946 with a 1-0 win.
UEFA Cup champion Sevilla - which plays Getafe in the Copa del Rey final on Saturday - finished third with 71 points. Zaragoza clinched the last UEFA Cup place with a 1-1 draw at Recreativo Huelva, while Atletico Madrid missed out on Europe for the seventh straight season despite beating Osasuna 2-1.
Athletic Bilbao avoided its first relegation with a 2-0 win over Levante and Edu Schmidt scored twice in the last 10 minutes as Real Betis also guaranteed its place in the first division with a 2-0 win at Racing Santander.
Real Sociedad dropped into the second division for the first time in 40 years after drawing 3-3 at Valencia, while Celta Vigo was relegated despite rallying for a 2-1 win over Getafe. Also, Deportivo La Coruna beat Espanyol 3-1.