NEW YORK -- For five innings, the New York Yankees sleepwalked against right-hander Chris Archer, hitting one pitch after another to those paid to record outs.
In the sixth, the Yankees awoke and drove two pitches to those who paid admission.
Catcher Brian McCann and designated hitter Alex Rodriguez homered on consecutive pitches by Archer with two outs in the sixth as the Yankees rallied for a 6-4 victory over the Tampa Bay Rays on Sunday.
"I thought our at-bats were pretty good against him all day," New York manager Joe Girardi said. "We seemed to hit them at people and he's obviously really good but we got a couple of guys on and it's been kind of our formula."
The Yankees (76-59) won for the seventh time in their last nine games, while remaining 1 1/2 games behind the Toronto Blue Jays for first place in the American League East.
The Yankees picked up the win on a day when they did little through five innings off Archer, who had won his first five decisions against New York.
"The guy is one of the best pitchers in the game," McCann said. "For us to scratch and claw (against him is huge)."
Archer (12-1) took a one-hitter into the sixth but the momentum began to swing in New York's favor when he put two on. He fell behind McCann and a 3-1 fastball wound up in the right field bleachers.
"I thought today Mac's (McCann's) home run was huge," Rodriguez said. "We were sleepwalking there about five innings and Archer basically dominated us but Mac has been huge all year."
While fans were still applauding McCann's game-tying home run, Rodriguez drove a first-pitch slider into the lower rows of the right field seats in a similar location as his 3,000th hit on June 19 against Detroit.
"I thought I hit the ball my first at-bat," Rodriguez said. "Second at-bat was not so good. The key with Archer or any ace is the same, you want to get a good pitch to hit and put your A swing."
McCann's 25th home run and Rodriguez's 28th home run marked the most runs the New York ever scored off Archer in nine meetings. It also ended Archer's road scoreless streak at 20 innings and before those home runs, he had allowed one extra base hit over the previous 79 hitters in road games.
"I didn't execute in the biggest moment of the game," said Archer, who allowed five runs (four earned) and six hits in 6 1/3 innings. "That's the danger of them having power one through seven in their lineup. I didn't execute."
The Yankees beat the Rays for the 10th time in 16 meetings and added insurance runs in the seventh and eighth. Shortstop Didi Gregorius scored on a throwing error by second baseman Logan Forsythe in the seventh and added a bases-loaded single in the eighth.
While the Yankees finally got to Archer, the Rays fell to 40-38 in games decided by two runs or fewer.
"We need to win every single game," Archer said. "We played good enough baseball to win but that's kind of the threat of playing in this division."
The Rays scored three two-out runs in the early innings off right-hander Ivan Nova (6-7), getting a two-run homer by center fielder Kevin Kiermaier in the second and a run-scoring single by Forsythe in the third.
Shortstop Asdrbubal Cabrera hit a solo home run for Tampa Bay, which lost the season series with New York for the first time since 2009.
Nova allowed three runs and six hits in six innings, ending a three-game losing streak.
Betances recovered after allowing Cabrera's 11th home run in the eighth and Andrew Miller gave up consecutive two-out hits in the ninth before getting his 31st save in 32 opportunities.
NOTES: Tampa Bay 3B Evan Longoria was in the lineup after exiting Saturday's game with a bruised right forearm. Manager Kevin Cash said Longoria told him he was good to go moments before the lineup card was posted. ... Yankees LHP CC Sabathia felt good Saturday and said he felt good while throwing a bullpen session Sunday. He conceded not wearing the brace he is wearing now earlier in the season was due to personal stubbornness. ... Tampa Bay OF Stephen Souza Jr. (fractured left hand) went 2-for-4 while playing DH in the first of three rehab games for Triple-A Durham on Saturday. ... In the wake of the innings limit controversy with New York Mets RHP Matt Harvey, Yankees manager Joe Girardi fielded 12 questions about the topic, prompting him to quip at one point, "I can only imagine what Terry is going through." Girardi said had RHPs Masahiro Tanaka and Michael Pineda not missed a month with injuries, they would have likely faced a limit. ... New York CF Jacoby Ellsbury returned to the lineup after exiting Friday with a stomach virus and entering Saturday's game in the seventh. He ended a hitless drought of 17 at-bats and is hitting .666 (14-of-21) against RHP Chris Archer.