BOSTON -- Hanley Ramirez created a wild walk-off finish for the Red Sox on Thursday night with a towering three-run homer off closer Dellin Betances to cap a stunning 7-5 victory over the Yankees at Fenway Park.
Ramirez's second career game-winning homer came with two outs and capped a five-run bottom of the ninth. Ramirez's homer, projected at 426 feet by Statcast™, was the longest that Betances has allowed this season. The drive had an exit velocity of 107 mph and was hit at a launch angle of 28 degrees. It came on a 99.3-mph pitch; just five homers in the Majors this year have been hit on faster pitches.
"I was trying to go to the moon," said Ramirez. "That's why I was sitting on a fastball the whole time. Just stay back and let it rip."
• Statcast™ of the Day: Hanley's HR dissected
For most of the night, the Yankees were in control. But it turned into a classic finish, even for this epic rivalry, thanks to several exciting plays in the late innings.
Boston was down, 5-1, before David Ortiz ripped a solo homer to center in the eighth for career homer No. 537, moving him past Mickey Mantle and into sole possession of 17th place on the all-time list.
Just minutes after the fantastic finish, Mookie Betts called it his best baseball moment.
"Some other guys have gotten into the playoffs and won World Series; for me, that's at the top of the list," said Betts, who drilled an RBI single to make it a one-run game just before Ramirez stepped up.
The comeback gave the Red Sox a two-game lead in the American League East over the Orioles, who lost to the Rays in Baltimore on Thursday. The fourth-place Yankees, meanwhile, fell to five games back in the division and three games behind the Blue Jays, who hold the second AL Wild Card spot and defeated the Angels on Thursday.
• Up-to-the-minute standings
A high spin rate is often what makes a four-seamer effective, as it gives the ball a "rising fastball" effect. The league average is 2,264 rpm, and Betances' final pitch (2,500 rpm) exceeded that level by a healthy margin. Betances' season average is 2,503.
"It's frustrating," Betances said. "This one, definitely, we had that game. You don't want to do that this late. Obviously, we're trying to win games; when that happens, you're not helping in any case. It's definitely frustrating. I just have to go out there and be better the next time out."
Yankees starter Masahiro Tanaka carved up the Red Sox, allowing four hits over seven innings of one-run ball and lowering his ERA to an AL-best 2.97.
Starlin Castro led the charge for the visitors with a four-hit, two-RBI night. Veteran Billy Butler had a nice debut for New York with a sacrifice fly and an RBI single.
"This one hurts; we've got to bounce back," Yankees manager Joe Girardi said. "We were in a pretty good position going into the ninth inning and weren't able to close the deal."
MOMENTS THAT MATTERED
Papi's laser beam: Naturally, Ortiz didn't pass Mantle with a run-of-the-mill homer. Instead, it was a majestic drive that Statcast™ measured with an exit velocity of 109 mph and a projected distance of 442 feet. That was tied with two other Ortiz moonshots for his longest homer of the season. Ortiz hit homers at that same projected distance on July 19 against the Giants and on Aug. 15 against the Indians.
• Papi out to cap career with one more ring
"I'm not really focused on any of that, any of those personal numbers," said Ortiz. "I'm focusing on winning. We need to win right now. We need to do whatever it takes to win. The race right now is very close."
Think fast: Red Sox reliever Joe Kelly got a thrill on the final out of the ninth inning, catching a scorching line drive off the bat of Yankees outfielder Mason Williams that had an exit velocity of 90.5 mph and a launch angle of 5 degrees, according to Statcast™. Such batted balls go for a hit 46.9 percent of the time.
"Thankfully, it was his glove and not his head," said Red Sox manager John Farrell. More >
Dig in for Country Breakfast: Added to the Yankees' roster earlier on Thursday, Butler arrived at the park about 90 minutes before game time and made an immediate impact with a first-inning sacrifice fly, a run-scoring single in the third and a run scored. Butler was released on Sunday by the Athletics, and the Yankees plan to use him as their designated hitter against left-handed pitching for the remainder of the regular season.
"That was definitely a tough loss," Butler said. "I've watched this series from afar, obviously, my whole career, and even before that. Yankees-Red Sox is a very passionate matchup, and the game's never over. It's back and forth, and tonight was definitely proof of that." More >
Missed opportunities: The Yankees always say that no lead seems safe at Fenway, and they had chances to pad their lead long before Betances faltered in the ninth. New York left two runners in scoring position in the third inning, couldn't get Didi Gregorius home after a leadoff double and steal of third in the fifth, saw Chase Headley get tagged out at the plate in the eighth and -- finally -- left the bases loaded in the ninth as Headley whiffed and Williams lined out.
"[Betances] was throwing 100 mph and Hanley got on top of one and hit it out, so don't put this one on Dellin," Headley said. "It was a game we had in hand. We had a chance to blow it open, and we didn't do it. That's how I see it."
• Working in 3rd straight game, Betances unravels
Feel-good story: It was Robby Scott, the 27-year-old pitcher the Red Sox signed out of the independent leagues, who helped set up the win with three scoreless innings. It was Scott's second career appearance in the Majors, and first at Fenway Park. After a disappointing start by Eduardo Rodriguez (2 1/3 innings, eight hits, four runs allowed), Boston's bullpen came up big with 6 2/3 nearly spotless innings. Kelly got the win by escaping a jam in the ninth.
"You could say that Robby Scott set this one up," said Farrell. "His three shutout innings were key."
"You know, coming from behind against a guy like Betances is huge. Betances is super-nasty. He has some of the best stuff in the game. It's big. It's really big." -- Ortiz
SOUND SMART WITH YOUR FRIENDS
The walk-off win was the third of the season for the Red Sox. It was the first time Boston has won on a walk-off homer since Mike Napoli hit one on June 8, 2014, against the Twins.
In the fifth inning, Gregorius attempted to steal third base moments after hitting a leadoff double. The tag by Travis Shaw was late, and Gregorius was called safe. The Red Sox challenged, however, and after a replay review lasting one minute and 29 seconds, it was ruled that the safe call at third would stand.
Yankees:Luis Cessa (4-1, 4.34 ERA) will make his sixth Major League start on Friday at 7:10 p.m. ET as the Yankees and Red Sox play the second game of this four-game weekend series. Cessa was handed his first loss last time out, serving up three home runs in a 4-2 loss to the Rays. The long ball has been an issue for Cessa, who has served up 13 in 47 2/3 big league innings.
Red Sox:Clay Buchholz draws the start in Friday's 7:10 p.m. ET contest at Fenway. The righty had been on a nice roll of late until his last start, when he gave up six runs, including a grand slam to Troy Tulowitzki, against the Blue Jays. Buchholz is 5-9 with a 6.19 ERA lifetime against the Yankees.
Watch every out-of-market regular-season game live on MLB.TV.
Ian Browne has covered the Red Sox for MLB.com since 2002.
Follow him on Twitter @IanMBrowne and Facebook.
Bryan Hoch has covered the Yankees for MLB.com since 2007.
Follow him on Twitter @bryanhoch, on Facebook and read his MLBlog, Bombers Beat.