David Beckham will leave Real Madrid and join Major League Soccer side LA Galaxy at the end of the season.
The 31-year-old former England captain will sign a five-year deal, reportedly worth £128m.
Beckham said: "This week Real asked me to make a decision regarding their offer to extend my contract.
"After considering several options to stay in Madrid or join other major British and European teams, I have decided to join LA Galaxy."
Interview: American sports journalist Sean Wheelock
Replay: David Beckham quits as England captain
In a statement, Beckham continued: "I would like to thank the supporters and people of Madrid who have made my family and I feel so welcome in my time here, making this an extremely difficult decision to make.
I am proud to have played for two of the biggest clubs in football
"I have enjoyed my time in Spain enormously and I am extremely grateful to the club for giving me the opportunity to play for such a great team and their amazing fans.
"I am proud to have played for two of the biggest clubs in football and I look forward to the new challenge of growing the world's most popular game in a country that is as passionate about its sport as my own.
"For the rest of this season I will continue to give 100% to my coach, team-mates and fans as I believe manager Fabio Capello will bring this club and its supporters the success they truly deserve."
Real Madrid confirmed Beckham's departure in a statement, saying: "Both parties have agreed that Beckham will not extend his current contract, which ends on 30 June 2007."
Beckham left Manchester United in July 2003 to sign for Real, who paid £25m for the midfielder's services.
However, in the three-and-a-half seasons since his arrival, the Spanish giants have failed to win any major trophies.
This season has proved particularly disappointing for Beckham, who was dropped by England coach Steve McClaren and then fell out of favour with Real boss Capello.
How the BBC Sport website broke the news in November
LA Galaxy admitted their interest in signing Beckham in November, when general manager Alexi Lalas told the BBC Sport website of his admiration for the former England captain.
In an exclusive interview, Lalas said: "The Los Angeles Galaxy are looked upon as the jewel of Major League Soccer.
"We play in the best stadium, we have had incredible success over the history of the league, we have had great individual players and great teams. There's a tradition of excellence.
"All of this leads to this race to become the first MLS super club, if you will.
"It is something we aspire to and in order to do that you have to have quality players, a direction and a passion, a good coach and you have to get credibility domestically and internationally.
"Signing players of Beckham's stature would be a wonderful step in the right direction not just for the Galaxy but for soccer in America."
He's won the FA Cup, Premiership, Champions League, been England captain and played for two of the best sides in the world - if he wants to go and play in America, I don't blame him
606: Have your say
Beckham is the biggest name to sign up for Major League Soccer since its inception in 1996 and the most famous player to play club football in the US since Pele, Franz Beckenbauer and Johan Cruyff competed in the North American Soccer League in the 1970s and early '80s.
LA Galaxy are owned by sports and entertainment giants AEG, who are also partners in Beckham's soccer academy in Los Angeles.
AEG president Timothy J. Leiweke said: "David Beckham will have a greater impact on soccer in America than any athlete has ever had on a sport globally.
"David is truly the only individual that can build the 'bridge' between soccer in America and the rest of the world."
Landon Donovan, Galaxy's star player, agreed that Beckham's arrival would be a huge boost to MLS.
"I think it's hard to quantify what David Beckham being here would mean," he said.
"Marketing-wise it's a dream come true and it's not a 35, 36-year-old washed-up guy.
"It's a guy who can still play and a guy who still has a lot of appeal, probably the most famous soccer player in the world."
£128m = about $250m for 5 years??
Beckham is as washed up as they come, still just 31 and has to ply his trade in america LOL