Eric Sogard also went deep with a solo shot for Oakland, which knocked three long balls in a game for the first time since May 2 -- a 98-game span and a club record.
Brandon McCarthy (7-6) earned the victory after blanking the Yankees for seven innings until yielding a three-run shot in the eighth to Nick Swisher.
The A's had to hang on for the victory, however, as New York rallied for two more in the ninth against closer Andrew Bailey. Coco Crisp tracked down a a Swisher blast near the center field wall with the bases loaded to end the game.
New York starter Bartolo Colon (8-8) gave up five runs on eight hits in a 6 1/3-inning effort.
The Yankees came into the contest holding a one-game lead over Boston atop the American League East.