BOSTON — Jacoby Ellsbury hit an inside-the-park homer and Conor Jackson added a grand slam to cap a much-needed offensive outburst that helped the Boston Red Sox split their doubleheader with the Baltimore Orioles tonight and stop, for now, their slide in the AL wild-card race.

The Red Sox won the late game 18-9 after losing the opener 6-5 for their 12th loss in 15 games, trimming their lead over Tampa Bay to 1½ games in the chase for the wild card. The lead is back to 2. The Rays were idle, with a four-game series against the New York Yankees starting Tuesday.

In the opener, Jeremy Guthrie (9-17) pitched the last-place Orioles to the win.

Boston rallied from a 6-2 deficit and cut the lead to two when a missed call cost the Red Sox a run and halted their comeback bid.

TV replays appeared to show that David Ortiz’s fifth-inning liner down the right-field line – ruled foul by first-base umpire Mike Estabrook – seemed to carom fair off the lower part of a short wall near the Pesky Pole with Pedroia on third after an RBI triple.

“That’s the breaks of the game,” Pedroia said. “We’ve played a hundred-something games. We’re not going to say the season’s over because an umpire missed a call.”

“Any loss hurts,” Boston Manager Terry Francona said. “We battled, and battled and battled and came up short. I’m glad we’re playing again right away.”

The Red Sox have five games remaining against Baltimore and three in New York against the Yankees. The Rays have 10 to play.

Robert Andino hit a two-run homer and Nolan Reimold followed with his 12th, putting the Orioles ahead 5-1 in the fourth. J.J. Hardy led off the fifth with his career-high 28th home run.

Baltimore won for the first time in six games at Fenway Park this year, getting outscored 40-20 in the five loses.

“These are some pressure games. I want to see those guys in those situations,” Orioles Manager Buck Showalter said. “Hopefully down the road they’ll be pitching in games that mean a little bit more for us.”

Guthrie pitched into the seventh inning for his first career win in Fenway Park. He had been 0-3 and the Orioles had lost all seven of his previous starts.

Marco Scutaro went 3 for 3 and scored twice for Boston. Darnell McDonald hit a solo homer for the Red Sox.

Guthrie was pulled after McDonald’s leadoff single in the seventh. He allowed four runs and 10 hits.

“It’s really nice,” Guthrie said. “Probably one of my favorite days as a baseball player.”

Jim Johnson, the sixth Orioles pitcher, worked a perfect ninth for his seventh save.

Leading 2-1 in the fourth, Baltimore roughed up Kyle Weiland (0-3) when Andino and Reimold hit consecutive homers into the Green Monster seats.

The Red Sox trailed 6-2 in the fifth before they mounted a comeback.

Adrian Gonzalez had an RBI double and Pedroia followed with a triple off the center-field wall, cutting it to 6-4 against Guthrie, before Ortiz’s drive was ruled foul.

“It’s huge,” Red Sox catcher Jarrod Saltalamacchia said. “Like I said, the game’s about momentum.”

After the umpires huddled in the middle of the diamond, the call was upheld. Francona argued along with Ortiz and first base coach Ron Johnson. Ortiz then flied to the track in center, pounding his helmet to the ground in frustration.

“I wish they could have kept asking somebody else, but they ran out of people to ask,” Francona said.

The Orioles took a 2-0 lead in the third when McDonald, inserted into the lineup when left fielder Carl Crawford was scratched with a stiff neck, lost Reimold’s fly ball in the sun. The ball ticked off his glove for a single, and McDonald then dropped Josh Bell’s for a two-base error before Matt Angle hit a two-run double over his leaping try against the wall.

McDonald, who came up to spattering of boos leading off in the bottom of the inning, homered into the Monster seats.

Weiland, making his fourth career start and his third against the Orioles, lasted just 4 2-3 innings, allowing six runs and five hits.

NOTES: Francona said OF J.D. Drew may see a doctor soon to check the “stability” of a broken middle finger and if all is well they may “move forward a little bit” toward his return. Drew has been sidelined since July 20 with a left shoulder injury and broke his finger on a rehab assignment. … Francona also said RHP Dan Wheeler has been bothered by forearm stiffness.