TORONTO _ Maybe this will be the game the Yankees look back on as the one that finally got their offense rolling the way it did during much of the season's first half.
Behind breakout games by rookie first baseman Garrett Cooper (four hits) and third baseman Todd Frazier, the Yankees erupted early, middle and late in topping the Blue Jays, 11-5, Wednesday night in front of 39,554 at Rogers Centre.
The Yankees (60-52), who had 17 hits, including three home runs, scored multiple runs in the second, fifth, eighth and ninth innings. They stayed four games behind the Red Sox in the AL East.
Frazier, 12 for 58 since joining the Yankees July 19, went 3 for 3 with three RBIs. Didi Gregorius went 3 for 5 with a homer and a double, giving him 27 hits in his last 73 at-bats.
The game in some ways was closer than the final score indicated.
Behind solo homers by Gary Sanchez, Frazier and Gregorius, the Yankees built a 6-2 fifth-inning lead. With a relatively fresh bullpen, they seemed primed to cruise to a victory.
But it nonetheless turned into a white knuckler as Masahiro Tanaka failed to make it out of the fifth inning and Chad Green and Tommy Kahnle weren't nearly as sharp as they had been, allowing the Blue Jays (53-60) to creep within one.
Finally, David Robertson started the process of settling things down, and a key two-run single by Ronald Torreyes in the eighth helped the Yankees open it up in escaping a somewhat wild night.
Nick Tepesch allowed Sanchez and Frazier to homer back to back in the second inning, and Gregorius went deep in the third. Tepesch, 28, allowed five runs and eight hits in 41/3 innings in only his third big-league start since 2014.
Frazier's two-run double off Leonel Campos in the fifth and Jacoby Ellsbury's ensuing double made it 6-2, giving Tanaka, who had command issues throughout, a cushion.
The right-hander, who was 3-3 with a 2.98 ERA in his previous eight starts, was not sharp, and he could not hold the Blue Jays (53-60) there in the fifth inning.
He allowed a leadoff homer to Jose Bautista, making it 6-3 and giving him 28 homers allowed in 23 starts this season. After Tanaka walked Josh Donaldson, Joe Girardi brought on Green, who struck out three straight.
Tanaka allowed three runs (two earned), two hits and five walks in four-plus innings.
Green, who came in ranked third among big-league relievers with a 1.41 ERA, allowed a one-out RBI double in the sixth that made it 6-4. Kahnle came on and threw a wild pitch, walked a batter _ his first walk in 11 appearances since joining the Yankees _ and allowed a two-out single to Donaldson that made it 6-5.
Robertson pitched a perfect seventh, and Torreyes' two-run single in the eighth pushed the lead to 8-5.
Dellin Betances pitched a scoreless eighth, and the Yankees made the ninth a non-save situation by scoring three runs in the top half, two of them coming in on the fourth hit of the night by Cooper, who initially was to start the game on the bench.
He was a late addition, however, when fellow rookie Clint Frazier was scratched because of tightness in his left oblique. Aaron Judge, the night's DH, went to right field, and Chase Headley, who was to start at first, shifted to DH.
The Yankees' bullpen came in with MLB's best ERA since the All-Star break (1.77). It allowed two runs, both charged to Green, in five innings.