BOSTON (AP) — Kiké Hernández’s game-tying RBI single caromed off the second-base bag and into shallow center field, sparking a three-run, seventh-inning rally that carried the AL wild-card leading Boston Red Sox to an 8-6 victory over the Baltimore Orioles Sunday and a sweep of their three-game series.

It was the fifth straight win for Boston, which leads Toronto by one game and the Yankees by 2 ½ in the playoff chase. The Blue Jays beat Minnesota, 5-3, on Sunday and New York lost to Cleveland, 11-1.

J.D. Martinez had a solo homer and Kevin Plawecki added a two-run single for the Red Sox.

“When it’s getting down to the end of the year and you don’t have a big lead and all the games matter, it gets to be a lot of fun,” Hernández said.

Trey Mancini had a three-run double for the Orioles, who lost 12 of the final 13 meetings against the Red Sox after sweeping a season-opening three-game series.

After giving up a two-run lead in the top of the seventh, Boston rallied against Conner Greene (1-1), getting the tying hit when Hernández’s grounder bounced off the bag, scoring José Iglesias.

“That’s exactly what I was trying to do. That’s how I drew it up,” Hernández said, smiling. “I was a little bit happy to get that hit and drive in that run.”

Hunter Renfroe followed with a double high off the Green Monster and scored on Rafael Devers’ single, making it 8-6.

“We got a little bit lucky with the ball off the bag,” Red Sox manager Alex Cora said. “Then Hunter put on a huge swing. ... Overall, another good win, obviously.”

The victory could be costly for the Red Sox after reliever Garrett Whitlock walked off the mound with right pectoral tightness. The 25-year-old Whitlock, a Rule 5 pickup from the Yankees, has been a strong part of their bullpen this season.

“We’ll know more (Monday),” Cora said of Whitlock. “It’s too soon to know what’s going on.”

Hirokazu Sawamura (5-1) was credited with the victory despite giving up a two-run lead in the seventh. Garrett Richards got the final three outs for his third save.

The Red Sox had jumped on starter Alexander Wells for three runs with two outs in the first when Bobby Dalbec got hit by a pitch with the bases loaded and Plawecki followed with his grounder to right.

They opened it to 5-3 on Martinez’s shot into the first row of Monster seats in the third.

But the Orioles rallied against Sawamura after Whitlock walked the leadoff batter, scoring three runs on Mancini’s double down the left-field line before they lost their major league-high 102nd game.

“This is huge, a huge amount of our team hasn’t played a lot of time in the majors,” Mancini said. “The teams we’re competing with the rest of the way, and have been basically the whole month, are fighting for a playoff spot.”

Boston starter Nathan Eovaldi struck out eight over five innings, allowing three runs on seven hits with one walk. The Red Sox have won his last six starts.

“The main focus is we’re winning these games,” Eovaldi said. “Things will even out (for me).”

Making his sixth major league start, the 24-year-old Wells gave up five runs in five innings.

“He gave four there in the first couple of innings,” Orioles manager Brandon Hyde said. “It was nice to see him put up a zero in the fourth and fifth. I was really happy with our offense.”

KEEP THE KID IN

When asked why left-handed hitting slugger Kyle Schwarber wasn’t in the lineup, Cora didn’t hesitate to explain the decision.

“This is more about Bobby Dalbec than anything else,” he said. “Bobby has to play against every lefty.”

The 26-year-old Dalbec, a right-handed hitter, has 12 homers and 36 RBIs in his last 33 games, overcoming early-season struggles that saw him hitting only .174 with one homer and six RBIs a month into the season.

CHASING O’S HISTORY

CF Cedric Mullins needs one more home run to become the first in Orioles’ history with 30 homers and 30 stolen bases.

IT FEELS RIGHT

It was the fifth straight game that the Red Sox faced a left-handed starter, and they’ve scored seven or more runs in all of those games.

TRAINER’S ROOM

Orioles: INF Ramon Urías was scratched from the original starting lineup with a right leg injury that’s been nagging him for about a month. “He tried to run this morning, just didn’t feel great,” Hyde said. … Mancini and C Pedro Severino were back in the lineup after having Saturday off.

Red Sox: Cora gave catcher Christian Vázquez the day off, figuring with an offday on Monday that two straight would be good for him.

UP NEXT

Orioles: LHP John Means (5-7, 3.41 ERA) is slated to go Monday night when they open a three-game, interleague series at the Phillies.

Red Sox: Off Monday before opening a two-game, interleague series against the New York Mets at Fenway Park on Tuesday. Red Sox LHP Eduardo Rodriguez (11-8, 5.00) is in line to start the opener against RHP Marcus Stroman (9-12, 2.88).