OAKLAND, Calif. - The Yankees were full-steam ahead toward a third straight loss to the team with the American League's worst record when they were rescued by a player who quietly has resurrected his season after a horrendous start.

Carlos Beltran, who looked cooked after the month of April, continued his solid May Saturday night, putting his team ahead for good with a two-run homer in the sixth inning and adding an RBI single in the eighth as the Yankees beat the A's, 5-3, in front of 25,223 at O.co Coliseum.

Beltran, hitting .162 with a .216 on-base percentage with no homers after April, entered the game hitting .299 with a .311 OBP, three homers and 11 RBIs in 23 games this month.

After Brian McCann worked a walk against A's righthander Jesse Hahn, Beltran, 38, blasted a 91-mph fastball to center to give the Yankees (26-24) a 4-3 lead. After Mark Teixeira reached on an infield single and stole second in the eighth, Beltran singled just in front of leftfielder Sam Fuld to make it 5-3.

The bullpen, called on early because Nathan Eovaldi lasted only 42/3 innings, struck out eight and allowed only one hit in 41/3 shutout innings.

After winning pitcher Chasen Shreve struck out all four batters he faced, Justin Wilson got the first two outs in the seventh. Dellin Betances got the next four outs, striking out three, and Andrew Miller pitched a perfect ninth to record his 15th save.

Eovaldi missed few barrels. He allowed eight hits in the first three innings -- he was fortunate to trail only 2-1 -- and allowed 11 hits and three runs in his 41/3 innings.

The Yankees, who scored eight first-inning runs in Eovaldi's previous start last Monday against the Royals, again gave the righthander an immediate, albeit smaller, lead.

Chase Headley singled with one out and Alex Rodriguez lined a single to center, pulling him within 16 hits of 3,000. After Mark Teixeira struck out, Brian McCann, who had homered in each of his last four games and wsa 9-for-23 in his last seven, singled to right to make it 1-0.

Rookie leftfielder Ramon Flores, called up earlier in the day to replace the injured Slade Heathcott, and McCann teamed to keep it that way in the bottom of the first.

With runners at first and second and two outs, Josh Reddick slapped a single to left. Flores charged and came up firing as A's third-base coach Mike Gallego waved Marcus Semien home. McCann applied the tag just before the sliding Semien touched home.

The A's (19-33) took a 2-1 lead in the third. Billy Burns, Semien and Stephen Vogt started the inning with consecutive singles to load the bases and Billy Butler smacked a sacrifice fly to deep center to tie it at 1-1. Reddick's hard single to right made it 2-1.

In the fourth, Eric Sogard made it four straight innings in which the A's leadoff batter singled. Two outs later, Semien singled to right for a 3-1 lead.

The A's reverted to the last-place team they are, at least in the field, in the fifth. Sogard, the second baseman, couldn't handle Jose Pirela's two-out grounder -- Pirela was awarded a hit -- and third baseman Brett Lawrie failed to hold Gardner's liner, which put Yankees at first and second. Headley (three hits) then singled to make it 3-2.