The Red Sox celebrate after Dustin Pedroia scores on an errant throw in the ninth inning — the Orioles’ third error in the final three innings — to cap a rally from five runs down that gives Boston a 6-5 victory over Baltimore at Fenway Park. (Jim Rogash/Getty Images)

Everything seemed to go the Orioles’ way for 51 / 2 innings against the Boston Red Sox on Sunday night at Fenway Park. Then everything unraveled.

They lost a five-run lead and Gold Glove shortstop J.J. Hardy to injury. Right-hander Ubaldo Jimenez lost his groove with one pitch that was sent into the Boston night, and the sure-handed Baltimore defense committed three errors in the final three innings to set the stage for a 6-5 loss to the Red Sox.

“That’s part of baseball,” Jimenez said. “That’s why it’s so tough, and sometimes you feel you have the game in your hand and then everything disappears.”

Left fielder David Lough was charged with a throwing error on the final play of the game when his throw home after catching the second out of the ninth inning was wide of the plate and bounced to the backstop, allowing Dustin Pedroia to score the winning run.

It was the weirdest game of the Orioles’ young season.

Third baseman Jonathan Schoop, whose seventh-inning throwing error allowed the tying run to score, took blame for not cutting off Lough’s throw on the final play.

“I should have caught the throw,” Schoop said.

Jimenez held the Red Sox scoreless over his first five innings before allowing a three-run homer to Jonny Gomes to left field on his 107th and final pitch with one out in the sixth inning.

After Hardy was forced from the game with a right hamstring strain in the seventh inning, the left side of the Orioles’ infield committed two costly errors as the Red Sox scored two runs in the seventh to tie it at 5.

Baltimore might have been out of the inning if not for the highly scrutinized interpretation of the transfer rule, which forces a player to make a clean transfer from his glove to his throwing hand for an out to be recorded.

With Brock Holt on first base and one out, Grady Sizemore hit a comebacker to left-hander Zach Britton, who threw to shortstop Ryan Flaherty for what could have been a double play.

Even though Flaherty reached out to catch the ball and had possession, he dropped the ball on the transfer, and Holt was called safe at second.

Boston went on to score two unearned runs off Britton. After Pedroia singled to load the bases, David Ortiz singled into right field to score one run. Mike Napoli then hit a ball to Schoop, who just moved from second base to third base, but Schoop wildly one-hopped a throw home, allowing the tying run to score.

“Yeah, you give a good team extra outs, they’ll make you pay, and that’s what they did to us,” Flaherty said.

Hardy, who missed six games earlier this month with lower back spasms but has never had hamstring problems, won’t play in Monday’s series finale.

Even though the outing was a step forward for Jimenez after losing his first three starts — he held Boston without a hit for the first 32 / 3 innings and made just one mistake on the homer to Gomes — he still has a 6.75 ERA and no quality starts.

The Orioles scored five runs off Jake Peavy, including Nelson Cruz’s third home run of the season in the first inning.

— Baltimore Sun