BOSTON — 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 to spoil a strong performance by starter Dean Kremer in a 5-3 loss.

Kremer recorded his fifth quality start in his last six tries, holding the Red Sox to one earned run over seven innings for his longest outing since April 30. After working through a couple jams early, 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 tough first half behind him and make a case for a spot in the Orioles’ playoff rotation.

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 Keegan Akin that helped the Red Sox win the series.

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 he set 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. Seranthony Domínguez 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 in an inning in which rookie second baseman Jackson Holliday allowed a runner to reach first on a fielding error and O’Neill cleared the Green Monster in left field to send Baltimore to its next series in Detroit on a sour note.