NEW YORK (AP) — J.D. Martinez hit a tiebreaking home run against Dellin Betances (1-2) leading off the eighth inning, just beyond Aaron Judge’s reach at the right-field wall, and the Boston Red Sox rebounded after wasting a four-run lead to beat New York 5-4 Thursday night and send the Yankees to only their second loss in 19 games.

In another dramatic game before a sellout crowd, Boston moved back into a tie with the Yankees for the AL East lead at 26-11, the best record in the major leagues. The rivals don’t meet again until June 29 in the Bronx.

Boston built a 4-0 lead against CC Sabathia as Hanley Ramirez drove in three runs with an RBI groundout in the first, an RBI single in a two-run third and a solo homer in the fifth just before a 55-minute rain delay. But the Yankees tied the score in the seventh.

Odubel Herrera added three hits and drove in two runs, extending his on-base streak to 39 games for the Phillies, who improved to 15-5 at home.

Gregor Blanco and Alen Hanson homered to give the Giants a 3-0 lead in the second inning before Velasquez (3-4) began a string of five straight strikeouts. The right-hander allowed five hits and helped the Giants set a dubious mark.

Santana, batting .153 entering May, continued his recent tear when he connected off Ty Blach (3-4) in a four-run fourth.

Freeman also homered for the Braves in that sixth-inning outburst, when Atlanta got all of its runs with two out. Albies also had a run-scoring single in the ninth to cap his five-RBI night.

The Braves have won eight straight games on the road, outscoring opponents 50-8 in that span. Atlanta starter Mike Foltynewicz (3-2) gave up three hits and one unearned run in five innings, and Luiz Gohara got a three-inning save.

BALTIMORE (AP) — Adam Jones homered, scored three runs and had three RBIs, and Baltimore outslugged Kansas City to emerge with its second winning streak of the season.

Manny Machado and Trey Mancini also went deep for the Orioles, who trailed 4-0 in the first inning and 6-3 in the second before rallying to beat the Royals for the second night in a row. The only other time Baltimore (10-27) won successive games this season was April 5-6 at Yankee Stadium.

DENVER (AP) — Lorenzo Cain homered on the first pitch of the game, Jhoulys Chacin kept his former team in check into the sixth inning and Milwaukee beat Colorado.

Cain lined a fastball from German Marquez (2-4) to deep center for his second career leadoff homer. The Milwaukee outfielder also accomplished feat on June 25, 2014, as a member of the Kansas City Royals.

Chacin (3-1) cruised along in the place where he kicked off his career, allowing two runs over 5 1/3 innings. Jeremy Jeffress struck out the side in the ninth for his third save in four chances.