The 31-year-old former Manchester United ace will sign a five-year deal with the club.
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.”
Beckham’s contract with LA Galaxy is reportedly worth £128m, and will comprise his salary, sponsorship contracts, merchandising shirt sales and a share of the club profits.
Beckham continued, in a statement: “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 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.”