BOSTON - The Yankees whacked the Braves over the weekend but failed to pick up ground on the Blue Jays, who swept their own series against the Tigers.

Monday night presented a rare opportunity -- rare in the last month, anyway. The Blue Jays, gasp, lost.

But the Yankees could not capitalize, as an offense that scored 38 runs in three games in Atlanta went cold in the clutch in a 4-3 loss to the Red Sox in front of 36,148 at Fenway Park.

The Yankees (72-58), who had 21 hits in Sunday's 20-6 victory over the Braves and went 12-for-21 with runners in scoring position, had 10 hits and eight walks Monday night but stranded 14. They remained 1½ games behind Toronto.

The lone offensive star was Didi Gregorius, who entered his final at-bat 4-for-4, making him 13-for-20 with 11 RBIs in the last five games. With a run home in the ninth, two outs and the bases loaded, he flied out to the warning track in rightfield on closer Jean Machi's 33rd pitch.

The Yankees loaded the bases with none out in the first but managed only one run. With a run home in the fourth on an RBI single by Gregorius, the bases loaded and none out, the Yankees failed to score again. They loaded the bases with two outs in the fifth but Greg Bird struck out to end the inning. With first and third and one out in the eighth, Jacoby Ellsbury grounded into a double play.

Ivan Nova allowed three runs and seven hits in six innings. Two of the hits were homers, a two-run shot by Mookie Betts and a solo blast by David Ortiz.

Red Sox rookie lefthander Eduardo Rodriguez was in trouble all night but allowed only two runs (one earned), seven hits and three walks in five innings.

The Yankees provided plenty of drama in the ninth against Machi. With the Red Sox leading 4-2, Stephen Drew singled and Alex Rodriguez walked with none out. After Carlos Beltran, hot of late, was called out on a borderline full-count pitch, a wild pitch advanced the runners. Brian McCann walked to load the bases for Chase Headley, who walked on four pitches to make it 4-3.

Bird was called out on strikes -- another borderline pitch on the inner half -- bringing up Gregorius.

The Red Sox (61-70), fresh off winning two of three at Citi Field over the weekend, handed the Yankees a run in the first. After Ryan Hanigan interfered with Ellsbury's swing for an error and third baseman Pablo Sandoval booted Chris Young's grounder for an error, Rodriguez singled to left to load the bases with none out. Beltran's sacrifice fly made it 1-0.

In the third, Jackie Bradley Jr. singled to left and Betts slammed a 95-mph fastball high atop the Monster Seats in left-center for his 14th homer of the season and a 2-1 Boston lead.

After Gregorius' single tied it in the fourth and loaded the bases with none out, Brendan Ryan dribbled a grounder back to the mound for a 1-2 putout. Ellsbury sent a liner to left, where Bradley made the catch, and threw a rope to the plate to nail Bird.

Ortiz led off the bottom of the inning by hitting a changeup into the first row of the Monster seats for his 29th homer of the season and 495th of his career.

Bird was unable to turn a potential inning-ending double play in the seventh, settling for one out as a run scored to give the Red Sox a 4-2 lead.