NEW YORK -- Alex Rodriguez and the Yankees settled their dispute over a marketing payment with a deal announced Friday that gives $3.5 million to charitable groups, saves the team $5.5 million and gets A-Rod the home run ball from his 3,000th hit.

At the time Rodriguez and the Yankees signed their $275 million, 10-year contract in December 2007, they reached a separate marketing agreement. It called for $6 million each for up to five milestone accomplishments in exchange for marketing rights, such as using A-Rod's name and image in selling licensed goods. The first was to be for A-Rod's 660th home run, tying Willie Mays for fourth on the career list.

The club's relationship with Rodriguez deteriorated during 2013, when he was a target of Major League Baseball's Biogenesis drug investigation. That led to A-Rod's suspension for the entire 2014 season after then-Commissioner Bud Selig concluded he violated the sport's drug agreement and labor contract. Rodriguez sued MLB, the players' union and the Yankees' team physician, then dropped the litigation.

Alex Rodriguez stood to make $6 million for tying Willie Mays on the home run list. Instead, $3.5 million will go to several charities. Adam Hunger/USA TODAY Sports

When the 39-year-old hit No. 660 on May 1, New York said it had the discretion not to make the payment and declined to do so, saying his marketing rights did not have any worth. MLB and the players' association stopped the clock on the time to file a grievance as negotiations continued.

Under the deal, the Yankees will split $1 million among the Special Operations Warrior Foundation, the Boys & Girls Club of Tampa and Pitch In For Baseball. The team has been a longtime funder of the Special Operations Warrior Foundation and the Boys & Girls Club of Tampa.

Zach Hample, the fan who retrieved Rodriguez's 3,000th hit at Yankee Stadium on June 19, supports Pitch In For Baseball, which says its mission is to assist children around the world through baseball. The charity was to receive $150,000, he said.

Hample was to give Rodriguez the ball at a news conference before New York played Tampa Bay on Friday night.

The Yankees will donate $2.5 million to the MLB Urban Youth Foundation, to be used in programs to increase youth participation in baseball, with a focus on urban areas. Baseball Commissioner Rob Manfred will pick the initiatives after speaking with Rodriguez, and Manfred promised to consider charitable activities the player has focused on.

In addition to saving $2.5 million -- the difference between the $6 million originally called for and the charitable payments the team agreed to make- the Yankees will save $3 million in luxury tax, since Rodriguez will not be receiving the money personally. New York pays at a 50 percent rate on the portion of its payroll above the $189 million threshold.