The 38-year-old former England captain, who recently won a league title in a fourth country with Paris Saint-Germain, said Thursday he will retire after the season.
"It's a good way to go out," Beckham said in Paris. "It's every athlete's dream, every footballer's dream to go out on the top — on top form or winning a trophy ... leaving as a champion."
Beckham, whose curling free kicks and pin-point crosses became his signature as a player, has two more matches left at PSG against Brest on Saturday and at Lorient on May 26. He has been giving his salary to a children's charity.
Asked what led to his decision, Beckham replied with a laugh: "Probably when (Lionel) Messi was running past me in that home game," referring to PSG's Champions League match against Barcelona last month.
Beckham started his career with Manchester United and also played for Real Madrid and the Los Angeles Galaxy, winning titles with all those clubs and also making a record 115 international appearances for an England outfield player.
FIFA President Sepp Blatter described the midfielder as "one of the most iconic figures in global football."
"It's the end of a chapter of an amazing story," Blatter wrote on Twitter. "David grew up as a football loving child & achieved his dreams, and unquestionably inspired millions of boys & girls to try & do the same.
"Whatever he chooses to do next I'm sure he'll approach with the same dedication & good grace he displayed the last 21 years."
Beckham's fame went beyond the field, with his haircuts and clothing scrutinized as often as his play, earning him a string of lucrative sponsorship deals.
"Sometimes that has overshadowed what I have done on the pitch or what I have achieved on the pitch," Beckham said in a television interview conducted by former United teammate Gary Neville. "And as much as I say that doesn't hurt me, of course it does.
"I am a footballer that has played for some of the biggest clubs in the world and played with some of the best players in the world, played under some of the biggest and best managers and achieved almost everything in football."
Beckham was even immortalized on the silver screen in the 2002 film "Bend it Like Beckham," which told the story of a British teenage girl of south Asian heritage struggling with family pressures and cultural expectations to play the sport she loves.
Beckham's retirement led to a flood of tweets dubbing the day "End it Like Beckham."
"If you had told me as a young boy I would have played for and won trophies with my boyhood club Manchester United, proudly captained and played for my country over one hundred times and lined up for some of the biggest clubs in the world, I would have told you it was a fantasy," said Beckham, who also played on loan at AC Milan. "I'm fortunate to have realized those dreams."
It was his appearances with England's national team that raised his profile internationally.
"To this day, one of my proudest achievements is captaining my country," Beckham said. "I knew every time I wore the Three Lions shirt, I was not only following in a long line of great players, I was also representing every fan that cared passionately about their country.
"I'm honoured to represent England both on and off the pitch."
Beckham is now living in London with his wife Victoria, a former "Spice Girls" singer, and their four children.
"I wouldn't have achieved what I have done today without my family. I'm grateful for my parents' sacrifice, which made me realize my dreams," he said. "I owe everything to Victoria and the kids, who have given me the inspiration and support to play at the highest level for such a long period."
Victoria Beckham said the couple is "excited about the next chapter in our lives."
"The children and I are so proud of David. It's been an incredible journey for us all as we have watched him play at clubs all over the world throughout the last 15 years," she said.
"Myself and the children have cheered him from the stands, as he has held high trophies ... this was not an easy decision to make, and to me and the children he will always be an amazing sportsman and a devoted husband and father. "
With United between 1992 and 2003, Beckham won six Premier League titles, the Champions League, two FA Cups and the Intercontinental Cup.
Beckham left United in 2003 shortly after manager Alex Ferguson accidentally struck Beckham's eye with a football boot. Ferguson announced his retirement from Manchester United last week.
Beckham spent four years in Madrid — winning the 2007 Spanish title before making the surprise move to Major League Soccer, where he won the title twice.
"I just want people to see me as a hardworking footballer," Beckham said. "Someone who is passionate about the game, somebody who every time I have stepped on the pitch I have given everything that I have."
There were highs and lows in Beckham's international career. He was blamed for England's elimination from the 1998 World Cup for his red card against Argentina, but scored the winning goal against the same team at the World Cup four years later.
Beckham responded to jeering at the 2000 European Championship with an obscene hand gesture to England fans, but was lauded by the same supporters little more than a year later when his last-minute free kick against Greece secured a place at the 2002 World Cup.
England dropped Beckham in August 2006 in an effort to renew the team with younger players after a quarter-final exit at that year's World Cup. England coach Steve McClaren recalled him the following year after a poor run of form, and he returned for the remainder of England's unsuccessful attempt to qualify for the 2008 European Championship.
His last England appearance came against Belarus in October 2009, and he missed the 2010 World Cup because of an Achilles injury. He still went to South Africa as part of Fabio Capello's backroom staff.
"I want to thank all my teammates, the great managers that I had the pleasure of learning from," Beckham said. "I also want to thank the fans who have all supported me and given me the strength to succeed."
Beckham had already started planning for his post-playing career earlier in the season, becoming an ambassador for Chinese football.
"Nothing will ever completely replace playing the game I love, however I feel like I'm starting a new adventure and I'm genuinely excited about what lies ahead," Beckham said. "I'm fortunate to have been given many opportunities throughout my career and now I feel it's my time to give back."
Beckham played a key role in helping London win the bid to host the 2012 Olympics. He also was involved in England's unsuccessful bid to host the 2018 World Cup, and the English Football Association wants to utilize his influence and star power in the future.
"He is an iconic figure in the game and produced wonderful performances for his clubs, particularly Manchester United," FA chairman David Bernstein said. "When you look at his playing and work for England, no one would ever accuse him of being unpatriotic and not giving everything for his country.
"He is a real loss to the game and I am sure the FA will want to embrace him and to get him closely associated with the organization."
Beckham's retirement comes a week after the 71-year-old Ferguson ended his managerial career.
"In the week following Sir Alex Ferguson retiring, which came as a bit of a shock, now we have the iconic David Beckham coming out of the game," Bernstein said.