The Diamondbacks will also get either a player to be named or cash in the deal that was completed before Thursday's trade deadline.
The 30-year-old Prado hit .270 with five home runs and 42 RBIs in 106 games this season. He is a career .290 hitter in nine seasons with Atlanta and Arizona.
Prado is the latest infielder acquired by the Yankees. They traded for Boston shortstop Stephen Drew earlier in the day, and he's likely to play second base for New York. They also got third baseman Chase Headley in a trade with San Diego earlier this month.
The 24-year-old O'Brien hit a combined 33 home runs with 70 RBIs in Double-A and Class A this year and played in the All-Star Futures Game this month.