David Beckham and Roberto Carlos departed Real Madrid as champions on Sunday when the Merengues won Spain's La Liga title for the 30th time with a 3-1 victory over Real Mallorca at the Bernabeu Stadium.

Real Madrid finished tied with Barcelona, a 5-1 winner over Gimnastic Tarragona, but captured the tie by virtue of its advantage in the tiebreaker (head-to-head play).

After a miserable first half of the season, Real Madrid recovered to chase down Barcelona and pull even with the two-time defending champion. As was often the case late in the season, the Merengues needed to come from behind to earn the win over Mallorca. They trailed at the half on Fernando Varela's early goal for Mallorca and looked to be in dangerous of falling further behind in the second half.

Without leading scorer Ruud van Nistelrooy, who left the game in the first half after appearing to pull a hamstring, the Real attack sputtered until substitute Jose Reyes saved the day. The former Arsenal striker equalized a minute after coming on in the second half for Beckham, who limped off in the 66th minute, and put the game away with a spectacular third seven minutes from time. Mahamadou Diarra, who had missed his African Nations Cup qualifier with Mali to play for Real Madrid, had the winning goal.

"I couldn't have dreamt it any better," said Beckham, who signed to play for MLS's Los Angeles Galaxy in January when Madrid was at its low point. "It's been about winning the title for the last six months, and we've deserved it tonight."

Roberto Carlos, 34, is leaving Real Madrid after 11 seasons to play for Turkish champion Fenerbahce.