NEW YORK -- Third baseman Josh Donaldson hit a go-ahead home run with one out in the top of the seventh inning as the Oakland Athletics rallied from a four-run deficit for a 7-4 victory over the New York Yankees on Wednesday night at Yankee Stadium.

Left fielder Yoenis Cespedes hit a pair of solo home runs in consecutive at-bats as Oakland won its fifth straight game and seventh in nine.

Two innings after Cespedes recorded his fourth career multi-home run game, Donaldson stepped in against Jose Ramirez (0-1), who was making his major league debut, in the seventh.

Donaldson then gave Oakland its only lead by driving a 1-0 fastball into the left-field seats. It was his 16th home run and his ninth in the last 23 games. It also marked the second straight season Donaldson has hit a go-ahead home run during the late innings in New York.

Oakland starter Jesse Chavez (5-3) hung in through six innings, allowing four runs and seven hits. He gave up all four runs in the third; but, after allowing a three-run home run to center fielder Jacoby Ellsbury with one out in that inning, he held the Yankees to one hit in seven at-bats with men on base.

Three relievers combined on three scoreless innings as Oakland beat the Yankees for the seventh time in the past eight meetings.

After Fernando Abad put two on in the seventh, Dan Otero pitched 1 2/3 scoreless innings and Sean Doolittle protected a three-run lead by working a scoreless ninth for his seventh save.

New York left-hander Vidal Nuno allowed two runs and six hits in 4 2/3 innings. He was lifted after allowing a sacrifice fly to shortstop Jed Lowrie.

The Yankees had runners on second and third with one out in the third inning after right fielder Ichiro Suzuki walked and left fielder Brett Gardner singled and stole second. They took a 1-0 lead on shortstop Derek Jeter's base hit to deep shortstop and a four-run lead on Ellsbury's three-run homer into the Yankees' bullpen beyond the right-center field wall.

Oakland scored its first run when Cespedes led off the fourth with a long home run to straightaway center field. Nuno allowed an infield hit to catcher Derek Norris but struck out right fielder Brandon Moss and retired first baseman Kyle Blanks on a double play.

The Athletics had the tying run up with nobody out in the fifth after designated hitter Alberto Callaspo walked and second baseman Nick Punto singled. Oakland made it 4-2 on a sacrifice fly on by Lowrie.

Oakland forged a 4-4 tie in the sixth by getting a leadoff home run from Cespedes against Matt Daley and a sacrifice fly by Callaspo that nearly was a grand slam off Matt Thornton.

Lowrie scored in the ninth when right fielder Brandon Moss was hit by a pitch with the bases loaded. First baseman Kyle Blanks hit a sac fly that scored Donaldson with the final run.

NOTES: The Yankees made some changes to their bullpen by recalling RHP Jose Ramirez from Triple-A Scranton/Wilkes-Barre and adding LHP Wade LeBlanc to the roster. To clear room for them, RHP Preston Claiborne was optioned to Scranton/Wilkes-Barre and RHP Alfredo Aceves was designated for assignment. ... The Yankees said DH Carlos Beltran is expected to return from the DL on Thursday after missing 21 games with an injured right elbow. ... Oakland gave OF Coco Crisp the night off to rest a lingering neck issue that initially surfaced when he ran into a wall last month in Seattle. ... According to Fox Sports, Oakland almost traded RHP Jim Johnson to the Miami Marlins last week for a competitive balance draft pick.