BOSTON (AP) — The Yankees and Red Sox have had their share of games decided by late rallies and towering home runs.

This time, it came down to a free pass.

Aroldis Chapman walked in the winning run without recording an out in the ninth inning, handing Boston a 5-4 win over New York on Friday night.

The Yankees hard-throwing closer gave up two runs in the ninth for his third blown save. New York entered tied for the major league lead with 17 blown saves.

"That happens to all pitchers," Chapman said. "Sometimes you get into a game and you have an inning like that where you're not as sharp as you would like to be."

Mookie Betts and Dustin Pedroia started the comeback with consecutive singles and a successful double steal. Betts scored when second baseman Ronald Torreyes booted Xander Bogaerts' groundball.

After an intentional walk to Hanley Ramirez, Chapman (2-1) walked Andrew Benintendi on five pitches to bring home Pedroia.

"That 3-1 pitch, I was about 90 percent take," Benintendi said. "It was gonna take a perfect pitch to swing at it."

It was New York's fourth walk-off loss of the season. The Yankees fell for just the second time this season when leading after eight innings. Chapman entered with a 6.75 ERA over his past five appearances.

Robby Scott (1-1) got the win for the Red Sox, who got their first victory over the Yankees at home this season. It was Boston's first game-ending walk since Sept. 23, 2000 against Baltimore.

Gary Sanchez had a two-run home run and an RBI single for the Yankees.

New York, which entered the four-game series 3 1/2 games behind AL East-leading Boston, had won four of the five previous meetings against its rival this season.

Drew Pomeranz was on the mound for Boston's lone victory this season against the Yankees last month in New York. Pomeranz had seven strikeouts Friday, but allowed some pitches to get up in the zone. New York took advantage, scoring three runs in the fifth.

While Pomeranz was off, manager John Farrell liked the relentlessness his teammates showed at the plate to stay in the game. Most of the praise went to Ramirez. He had two hits and put the Red Sox up early, crushing his 14th home run over the left-center field fence in the third.

"He's swinging the bat like he did the second half of last year," Farrell said. "To be quite frank, we need that type of production, and he's certainly very capable."

The Red Sox had a chance to get the lead back with runners on the corners in the seventh, but Benintendi's long fly ball to center was reeled in on the warning track by Jacoby Ellsbury.

The Yankees struck first, getting on the board in their half of the third inning. Sanchez hit a hard liner that deflected off Bogaerts' glove at shortstop and fell into left field, scoring Chase Headley. New York pulled within 3-2 in fifth on an RBI single by Brett Gardner to set up Sanchez's go-ahead homer.

PLUGGING HOLES

Injuries ravished the Yankees prior to the All-Star break and they continued to work to make lineup adjustments on Friday.

With first baseman Greg Bird still out with an injured ankle, Garrett Cooper made his major league debut a day after coming over in a trade with Milwaukee. Cooper became the eighth player to start at first for New York this season.

The Yankees also said that starting pitcher Michael Pineda could be facing Tommy John surgery on his pitching elbow.

New York did get a little good news as Matt Holliday (illness) returned to the lineup.

TRAINER'S ROOM

Yankees: Pineda was placed on the 10-day disabled list for the ulnar collateral ligament injury, and general manager Brian Cashman said it was the recommendation of the team for him to have Tommy John surgery. Pineda will get a second opinion before making a decision. ... Bird could require surgery for his right ankle, which hasn't responded to a cortisone shot.

Red Sox: Farrell said Brock Holt (vertigo) "is close" to returning from the 60-day disabled list. He was slated to DH with Triple-A Pawtucket on Friday and could make a position start there on Saturday.

UP NEXT

Yankees: RHP Luis Severino (5-4, 3.54 ERA) is winless in his last five starts. Severino was selected the American League All-Star team but did not play in the game Tuesday.

Red Sox: LHP Chris Sale (11-4, 2.75) makes his first start since taking the loss July 6 against Tampa Bay. Sale leads the AL in strikeouts with 178 and is 6-1 in eight starts at Fenway Park this season.

___

More AP baseball: https://apnews.com/tag/MLBbaseball

___

Follow Kyle Hightower on Twitter at http://www.twitter.com/khightower