BOSTON — Hanley Ramirez officially assumed the Big Papi role for the Boston Red Sox on Wednesday afternoon.

In a moment that retired Boston slugger David Ortiz often flourished in, with the Red Sox down two runs in the late innings, Ramirez delivered the game-tying blow.

Ramirez’s two-run double to center field with one out and the bases loaded in the eighth erased the deficit, and Xander Bogaerts brought him home shortly thereafter as the Red Sox rallied past the Pittsburgh Pirates 4-3 at Fenway Park.

“When they choose to pitch to Hanley, he puts a beautiful swing on a pitch to give us extra bases when we needed it most,” Boston manager John Farrell said.

Ramirez appeared to give Boston (5-4) the lead after his two-bagger cleared the bases.

However, the Pirates challenged home plate umpire Gabe Morales’ ruling that trailing runner Mookie Betts was safe at the plate, and the call was overturned.

Betts was merely a few feet behind Andrew Benintendi, who held up just past second base to make sure Pirates center fielder Starling Marte didn’t make the catch, as he attempted to score from first.

But Ramirez took third on the throw and scored on Bogaerts’ opposite-field single to right, making the close call an afterthought.

“It’s a bang-bang play with Mookie, but fortunately Bogey makes it all go away,” Farrell said.

Thursday’s game was a make-up after last Thursday’s series finale was rained out.

Pittsburgh (3-6) lost 5-3 on Opening Day last Monday in Boston and was blanked 3-0 in the second game Wednesday. The Pirates entered the make-up game coming off a three-game sweep against the Cincinnati Reds.

“We play 162 in the regular season. I’ve been around long enough to know it doesn’t matter right now,” Pirates star Andrew McCutchen said. “You’re going to battle, you’re going to win, you’re going to lose. And that’s what it’s all about.”

McCutchen, a combined 0-for-9 with three strikeouts in the first two games at Fenway last week, launched a two-run homer. It was the 176th of his career, tying Barry Bonds for the fourth-most in Pirates history.

Marco Hernandez also had an RBI for Boston. Mitch Moreland doubled in his Red Sox-record seventh straight game and leads the majors with eight two-baggers.

“It’s not something I’m really concentrating on,” Moreland said. “When I go to the plate, I’m trying to keep it as simple as possible, get a good pitch to hit and try to get the barrel to it. If they go for doubles, I’ll take them all day long.”

The major league record for consecutive games with a double is eight, shared by Derrek Lee (2007) an Yadier Molina (2016).

Matt Barnes (2-0) was the winning pitcher for Boston with a scoreless eighth. Craig Kimbrel tossed a scoreless ninth for his third save.

Juan Nicasio (0-2) gave up the winning single to Bogaerts after Daniel Hudson coughed up the tying runs to Ramirez.

Red Sox starter Eduardo Rodriguez was tagged for three runs (two earned) on four hits and four walks while striking out eight in a 5 1/3-inning no-decision.

Pirates starter Chad Kuhl held the Red Sox to one run on five hits and struck out six over 6 1/3 innings.

“Chad pitched a fantastic game,” Pittsburgh skipper Clint Hurdle said. “To hold that offense in check, to pitch into the seventh, no walks, six strikeouts, the fastball command was excellent.”

Pittsburgh enjoyed a quick start this time around after failing to advance a runner past first base in last Wednesday’s game at Fenway.

McCutchen blasted a first-pitch fastball from Rodriguez off the AAA sign on the Green Monster in left field following a walk to Jordy Mercer, putting the Pirates up 2-0 in the first.

Boston got a run back in the second on Hernandez’s one-out double off the wall in left that plated Moreland from second.

Gregory Polanco stole third and scrambled home after Red Sox catcher Christian Vazquez’s throw sailed into left field with two down in the sixth, restoring Pittsburgh’s two-run lead.

NOTES: Pittsburgh RF Andrew McCutchen’s homer was the first ever for a Pirates hitter at Fenway Park. … Boston activated LHP Robbie Ross Jr. from the 10-day disabled list and optioned RHP Ben Taylor to Triple-A Pawtucket. Ross went on the DL last Thursday (retroactive to April 3) with influenza. … Red Sox LHP David Price (left elbow strain) threw from 90 feet Thursday and will throw a 45-pitch bullpen Saturday. RHP Tyler Thornburg (right shoulder impingement) also threw from 90 feet and INF Josh Rutledge (left hamstring strain) took ground balls before the game. … Pittsburgh visits the Chicago Cubs while Boston hosts the Tampa Bay Rays on Friday. Pirates RHP Gerrit Cole (0-1, 6.55 ERA) faces Cubs RHP Kyle Hendricks (1-0, 6.00 ERA) and Red Sox RHP Rick Porcello (1-0, 4.38 ERA) opposes Rays RHP Chris Archer (1-0, 2.45 ERA).

Orioles 12, Red Sox 5

Wednesday night’s game

BOSTON — Rookie Trey Mancini hit two of Baltimore’s five home runs in the first three innings and the Orioles pounded out 17 hits en route to a 12-5 victory over the Red Sox on Wednesday night.

Mancini, a right-handed batter getting the start in left field over lefty-swinging Hyun Soo Kim against knuckleballer Steven Wright, hit one of the four homers yielded by Wright in 1 1/3 innings. Mancini belted his fifth homer in 29 major league plate appearances off reliever Ben Taylor in the third inning.

Mancini, who has 10 RBIs in 10 big league games, and Jonathan Schoop went back-to-back in the first inning. Adam Jones and Chris Davis homered to chase Wright (0-1) in the second as Baltimore (5-2) built a 9-0 lead and went on to a split of the two-game series.

Ubaldo Jimenez, 2-6 lifetime against the Red Sox, couldn’t get through five innings for the win as Mychal Givens was summoned with the bases loaded in the fifth. Givens (2-0) gave up an RBI single — one of Xander Bogaerts’ three hits — but was credited with two scoreless innings.

Welington Castillo doubled home two runs among his three hits and Schoop added an RBI single in a three-run seventh.

Davis had a single and double to go with his homer, Mark Trumbo had an RBI single and two hits and Jones, J.J. Hardy and Schoop had two hits apiece. Schoop and Hardy came into the game 2-for-19 on the season.

Boston’s Pablo Sandoval, who hit into a double play his first time up, hit a two-run homer in the fourth inning but also struck out with the bases loaded in the fifth, fouled out with two men on in the seventh and popped out with two men on to end the game.

Mitch Moreland had a seventh-inning double for Boston (4-4) — his sixth straight game with a double.

Wright needed a leaping catch in left field by Chris Young to get out of the first inning.

The Red Sox got one run back on an Andrew Benintendi sacrifice fly in the third, Bogaerts’ RBI single made it 9-2 in the fourth and Sandoval then dropped one over the Green Monster later in the inning to make it 9-4.

Wright allowed eight runs on eight hits in 1 1/3 innings. Jimenez yielded five runs on eight hits in 4 1/3 innings.