BOSTON — That was a gut punch.

The Orioles entered their series finale against the Red Sox on Wednesday hoping to build off the momentum of an uplifting Tuesday night victory. Instead, all-too-familiar offensive woes resurfaced once again and Keegan Akin unraveled in the 10th inning to spoil a strong performance by starting pitcher Dean Kremer in a 5-3 loss.

“I thought we were really unlucky offensively the last third of the game,” manager Brandon Hyde said. “I thought we hit a lot of balls hard. Credit to them, they made some nice plays defensively, too. But they just got the big hit tonight.”

Kremer recorded his fifth quality start in six tries, holding the Red Sox to one earned run over seven innings for his longest outing since April 30. After working through a few early jams, the right-hander leaned on his fastball and settled in to retire the final 10 batters he faced. He lowered his season ERA to 4.10 as he continued to put a rough first half behind him and make a case for a spot in the Orioles’ playoff rotation.

“I gave the team a chance to win,” Kremer said. “It’s my job. I feel like I accomplished it tonight.”

Yet Baltimore’s offense struggled to get much going against Red Sox starter Nick Pivetta, scraping one run across on a solo home run by Emmanuel Rivera in the third inning. Anthony Santander tied the game with his 41st long ball of the season against the Boston bullpen in the eighth, but the rest of the lineup stalled from there to set up a walk-off, three-run home run by Tyler O’Neill off Akin that gave the Red Sox the series win.

“Just made a bad pitch,” Akin said. “Paid the price for it. Had to be at a crucial point in the game, obviously. But it’s baseball, it’s going to happen.”

The Orioles (83-64) went 1-for-6 with runners in scoring position and stranded six base runners, only advancing one runner to third base in nine innings save for the two home runs. A throwing error by Rivera in the third loomed large as well; he charged a slow ground ball for a potential inning-ending play but threw the ball into the camera well on the first base line to allow an unearned run to score against Kremer.

Boston tacked on another run on an RBI single by Ceddanne Rafaela the following inning to make it 2-1, and that’s where the score stayed until the top of the eighth. With Pivetta out of the game, Red Sox manager Alex Cora turned to setup man Justin Slaten.

The rookie right-hander had allowed just one run in his past eight appearances, but Santander stepped to the plate with two outs and crushed the first pitch he saw 408 feet to right field. He stood and watched as the high fly ball, which would’ve been a homer in all 30 MLB parks, landed in the seats before beginning his trot around the bases. Santander raised his RBI total to 95 with the blast, tying his career high from last season.

Cionel Pérez and Yennier Cano combined for a scoreless bottom of the eighth, with Cano inheriting two runners and stranding them on a popup by pinch hitter Enmanuel Valdez. Cano, who pitched Tuesday, didn’t return to the mound for the ninth despite throwing only two pitches. Hyde instead went with Seranthony Domínguez, who worked around a single by first baseman Triston Casas and a wild pitch that moved pinch runner Nick Sogard into scoring position for a scoreless ninth.

But after Rivera put the Orioles ahead on an RBI single to score the automatic runner Austin Slater in the top half of the 10th, Akin couldn’t finish the job. He struck out third baseman Rafael Devers for the first out before rookie second baseman Jackson Holliday allowed a runner to reach first on a fielding error. With right-hander Matt Bowman warming in the bullpen and a base open, Hyde stuck with Akin against the right-handed O’Neill and he cleared the Green Monster in left field to hand Baltimore a crushing loss.

“You’ve still got [Rob] Refsnyder over there [on the bench] too,” Hyde said of why he decided not to intentionally walk O’Neill. “I could bring Bowman in there with the bases loaded. Hoping we wouldn’t give O’Neill something good to hit.”

The Orioles have dropped two consecutive series against the division rival Red Sox and Tampa Bay Rays. With the Yankees beating the Kansas City Royals, 4-3, in 11 innings to take two of three in their series, the Orioles fell back to 1 1/2 games behind New York in the American League East race.

Fifteen games remain on the Orioles’ schedule. They don’t yet have an answer for why they haven’t been able to round into form.

“I wish that was my job to tell you, but that’s not my job,” Kremer said when asked for his assessment of the team’s overall inconsistency. “My job is to go out there and pitch. That’s a question for the higher-ups, the guys who make the decisions of who plays, who doesn’t play and all that stuff. So, I wish I could tell you but I got no answer for that.”