The Yankees, down 7-2, surged back for six runs in a stunning bottom of the seventh to take the lead.
But with two outs and nobody on base in the top of the ninth, the Red Sox got up off the mat against Mariano Rivera, perhaps the best closer of all-time.
How does a team conquer such a predicament?
"Scramble," said manager John Farrell. "Do what you can."
That started with Mike Napoli, down to his team's last strike, going the other way for a single to right-center.
Quintin Berry came on as a pinch-runner and gave Boston fans visions of Dave Roberts from the 2004 American League Championship Series when he stole second and moved to third on catcher Austin Romine's throwing error.
In 22 career stolen-base attempts in the Majors, Berry has never been thrown out. What does he make of the mention that he could be this year's Roberts for the Red Sox?
"It's a high pedestal, but I'm for the challenge," Berry said. "If I can help this ballclub the way he did, it would be a dream come true. I can tell with this ballclub and the guys that we have and the offense we have, there's not going to be very many opportunities just because we pitch so well and we hit so well, as you see every night. When I do get that opportunity, I try to make the most of it."
Berry's crucial steal set up Stephen Drew for a game-tying single to right.
"The pitch was in," said Drew. "I was trying to get my hands inside. He broke my bat, but just got enough to get it. He's the best in the game at what he does. He's been fun to watch on the other side, but getting out there with two outs and trying to do your job, he makes it tough. He's been doing it his whole career. It's just one of those things where it worked out for me tonight."
In his final season, it was Rivera's sixth blown save in 47 opportunities.
"Again, it's part of the game," Rivera said. "Sometimes you hit the ball hard right at someone, sometimes it's a broken bat. It was a tough one. We just have to forget about it and come in tomorrow."
The Sox surged back in front in the 10th. Jacoby Ellsbury belted a one-out single to right against Joba Chamberlain and stole second. Shane Victorino, who has come through with countless big hits in the late innings this season, did it again by smacking a go-ahead RBI single to right.
Chamberlain thought Victorino had gone around enough on the previous pitch to get a strikeout. But first-base umpire Joe West ruled that Victorino checked his swing.
"Well, it's a borderline call," said Farrell. "We may have caught a break there. I don't know without seeing the replay, but in the end, it gives him a breath of life still and he fights off a fastball from Chamberlain for the go-ahead run."
It looked like it was going to be a close play at the plate, but Romine dropped the throw.
"I knew I had a pretty good shot of scoring," said Ellsbury. "Once it got over the infield, Shane hit a nice line drive and I was pretty confident I was going to score. I hesitated just a split second. But once I went, I had a pretty good secondary lead. I had to freeze for a split second just to make sure it got through."
It was the 10th win in the past 12 games for the surging Red Sox and it cooled off the Yankees, who had won seven out of 10 heading into this four-game rivalry showdown.
Of the 85 wins the Red Sox have had this season, this one ranked as one of the sweetest.
"It is," said Drew. "We had to come back. It's one of those things. They battled back, put some good ABs together. Timely hitting just like we did at the start of the game. It was a battle. It was a big game for us to win. It definitely would have hurt us. We're up 7-2 I think, 7-3, somewhere in there. It's a good feeling to get this win."
After Matt Thornton and Junichi Tazawa faltered so dramatically in the seventh, Craig Breslow gave the Sox just what they needed, firing two scoreless innings to earn the win.
Red-hot closer Koji Uehara worked a scoreless 10th to earn the save. The right-hander has retired the last 24 batters he's faced and has a 1.14 ERA on the season.
"To have the anchor back there, it allows everyone to fall in line behind the starter to bridge back to him," Farrell said. "Unfortunately tonight it didn't map out where you're looking to match up as best you can. Knowing that you've got him available to us, it's a luxury for us right now."
The Red Sox opened their lead to a season-high 6 1/2 games in the AL East, reducing their magic number to 16.
Jake Peavy's rivalry debut looked like it was going to lead to his first win in five career starts against the Yankees.
When Peavy took the mound to open that fateful seventh, he had a commanding 7-2 lead. After he gave up a walk to Ichiro Suzuki and a single to Vernon Wells to reach 117 pitches, Farrell came out to get him.
"You can't start the seventh the way we started the seventh," said Peavy. "We didn't have great flow and rhythm to the game. It's a win. I'm happy to be talking to you guys after a win."
One Peavy left, everything went downhill for a while. Lefty Thornton was the first one out of the bullpen, and he gave the Yankees life. Brett Gardner greeted him with an RBI single. Derek Jeter drew a walk. Wells stole third, which became important when Robinson Cano drove him home on a fielder's-choice grounder.
Clinging to a 7-4 lead, Farrell went to righty Tazawa. That didn't go well either. Alfonso Soriano stroked an opposite-field RBI single. Curtis Granderson belted an RBI double to right to make it a one-run game.
Tazawa got a temporary reprieve when he struck out Alex Rodriguez. But the benefit of that strikeout was nullified when Lyle Overbay ripped a two-run single through the hole at second base and into right. With the crowd roaring with approval, the Yankees suddenly had an 8-7 lead
"I felt like where we were in the bottom of the order with a five-run lead, [Peavy] was still in decent shape," said Farrell. "Unfortunately the two guys get on and then we end up bringing in relievers with men on base, rather than a clean inning to start. Yeah, it worked against us tonight."
But the Red Sox were still able to stay on course and pull out the win, even when Rivera had them down to their last strike.
"You don't see that happen too often," said slugger David Ortiz, "but it happens. It's part of the game. Playing the game, facing one of the greatest, it seems like you don't have too many chances, but the game isn't over till there's a result, so keep on playing."
Offensively, the Red Sox, backed by homers from Will Middlebrooks and Victorino, did a solid job against Ivan Nova, who was the AL's Pitcher of the Month in August.
But even with what seemed to be a safe lead for Boston, there were a couple of momentum swings left.
"[Example] of the grit and the play to the 27th out that has been the case many times over this year," said Farrell.