NEW YORK (AP) -- Grant Balfour was angry.
He had just given up a broken-bat single to Brett Gardner and thrown a wild pitch to Robinson Cano, moving the potential tying run to second base with two outs in the ninth inning.
Oakland manager Bob Melvin called for an intentional walk.
''I don't make the decisions. He felt that that was the decision to make. That's not really for me to answer on this stuff,'' the Athletics closer said.
Up came Vernon Wells, 6 for 12 with two homers and two doubles against Balfour in his career.
Balfour fell behind 2-1 in the count, got two foul balls, then got Wells to swing over a 92 mph fastball, saving Oakland's 5-4 win over the New York Yankees on Sunday.
''I guess I got lucky today facing Wells then, with the history,'' Balfour said.
Andy Pettitte had his second straight shaky outing for New York, allowing Luke Montz's solo home in the fourth - his first in 4 1-2 years - and Yoenis Cespedes' two-run homer in the fifth. After the Yankees rallied in the sixth against Jerry Blevins to tie the score 4-4, Josh Donaldson homered into the left-field second deck in the eighth off Boone Logan (2-2).
Balfour retired Chris Nelson on a lineout to right and struck out pinch-hitter Brennan Boesch before Gardner's hit. Cano, 4 for 12 against Balfour, took a called strike before the reliever bounced a curveball, which nicked the wrist of catcher Derek Norris, temporarily creating some numbness.
Melvin didn't hesitate to call for the walk.
''Trust me, I know it's 6 for 12 and two homers sitting right behind him,'' he said, ''but in this ballpark and the way Cano is swinging, it was a better option for me.''
Balfour got his fifth save and his 23rd in a row in a streak that began on May 5 last year.
He would have rather ended the game by retiring Cano, who leads the Yankees with eight home runs.
''I was fired up. I want to face him. I want to get him out,'' Balfour said. ''It was a 1-1 count. I felt good about it. Like I said, it was Bob's decision to make.''
Sean Doolittle (2-0) pitched a perfect seventh, and Ryan Cook got out of a two-on, one-out jam in the eighth by striking out Jayson Nix and retiring Lyle Overbay on a flyout to deep center. Oakland has won seven of its last 10 games against the Yankees.
''I've been through so many unnerving ninths, either here or in the other ballpark, that I know you literally have to play 27 outs and three strikes on the last out to get a win here,'' Melvin said.
New York, missing five regular starters who are on the disabled list, lost for just the third time on its 10-game homestand.
''We had chances in the eighth and the ninth,'' Yankees manager Joe Girardi said. ''I assumed we might get it done.''
Oakland went ahead in the third on Cano's throwing error at second, then he tied it with an RBI single in the bottom half.
Montz, called up from the minors after Coco Crisp and Chris Young were injured in Tuesday's 19-inning win against the Los Angeles Angels, homered leading off the fourth. It was just his second big league homer and first since Sept. 28, 2008, for Washington.
''2008 seems like a long time ago. It felt like my first one again today,'' he said. ''Being at Yankee Stadium against Pettitte, made it that much more impressive. Big game, big win.''
Cespedes homered into the visiting bullpen in left for a 4-1 lead in the fifth. After he crossed the plate and exchanged high-fives with teammates, he waved to his mother, Estela Milanes, who was sitting behind the third-base dugout. The Cuban defector was reunited with his family members earlier this year.
New York tied the score in the sixth, when Oakland starter Dan Straily allowed Cano's leadoff single and a one-out walk to Travis Hafner. While Straily had thrown just 85 pitches, Melvin brought in left-hander Jerry Blevins to face Ichiro Suzuki, 6 for 16 off him coming in.
''I was a bit shocked,'' said Straily, who respected Melvin's decision.
Suzuki reached out to hook an RBI double to right and Nix struck out, but Overbay fouled off three two-strike pitches and singled softly to center, driving in two runs.
''I just didn't want him out there and a couple more guys get on,'' Melvin said. ''Blevins has been so good for us in those situations.''
NOTES: Josh Reddick had been 0 for 33 at new Yankee Stadium before doubling to lead off the ninth. ... Oakland is 13-4 when Cespedes starts, 5-10 when he doesn't. He has two homers and nine RBIs since coming off the DL on April 28. ''Even when he's not swinging well, he makes everybody in the lineup better,'' Melvin said. ''You know you're more apt to pass the baton and not feel like you have to be the guy to knock in runs and be the guy.'' ... The A's won their season series at Yankee Stadium for the first time since 2007.