Ryan Lavarnway hit his first two career home 7 decision over Baltimore in the middle test of a game series.

Marco Scutaro and Jacoby Ellsbury each hit a two-run homer for the Red Sox, who kept pace with Tampa Bay in a tie atop the AL wild card standings with one game remaining.

The Rays downed the Yankees, and both clubs remained tied with identical 90-71 records.

"I think it's really good for baseball, not so good for my stomach," Red Sox manager Terry Francona said. "It's exciting. If you don't want to show up tomorrow and play, you've got no pulse. I can't remember being that nervous in a long time."

Alfredo Aceves (10-2) worked 3 2/3 relief innings, earning the win by scattering three hits and one run. He filled in admirably for starter Erik Bedard, who lasted only 3 1/3 frames and allowed three runs on five hits with three walks and six strikeouts.

Jonathan Papelbon barely survived a first-and-third, one-out jam in the ninth, giving up a run on a Matt Wieters groundout before finally getting Adam Jones on a bouncer to third in a protracted last at-bat with the tying run at second base.

"They needed to win this more than we did," Jones said. "All the pressure is on them."

Wieters connected for a two-run blast and scored twice, while Jones also homered for the Orioles, who took Monday's opener.

Zach Britton (11-11) served up seven hits and five runs over 4 1/3 innings to take the loss.

Down 8-4, the O's began their comeback against Daniel Bard in the home eighth. Wieters led off with a single and advanced on a Jones groundout, and after Mark Reynolds fanned swinging, Chris Davis plated Wieters with a single and came in himself when Robert Andino followed with a triple.

Papelbon got into trouble by allowing a leadoff single to J.J. Hardy, who moved up on a Nick Markakis groundout. Vladimir Guerrero bounced a single past Sox third baseman Jed Lowrie to put runners on the corners, then Wieters almost beat out his dribbler to score Hardy for an 8-7 game.

Jones made the fiery closer work, but eventually grounded to Lowrie on a 3-2 pitch to end the game.

Baltimore picked up a two-out run in the first, as Markakis walked and scored on a double to the gap in left-center from Guerrero.

Boston countered in the third, as Scutaro doubled with two down and Ellsbury followed by clearing the wall in right center.

It was 5-1 for the Sox in the fourth as David Ortiz led off with a single, Adrian Gonzalez added a one-out hit and Lavarnway struck for his first career homer, a three-run shot to left.

After Guerrero singled to start the home portion, Wieters cleared the wall in center to make it a two-run game. Bedard exited after walking Reynolds and allowing a hit to Davis, but Alfredo Aceves retired the next two batters.

In the top of the sixth, Carl Crawford slugged a one-out triple and scored as Scutaro deposited a ball into the seats in left center to give the Red Sox a 7-3 advantage.

Jones started the home sixth with a blast to right center, but Lavarnway launched a pitch just over the wall in left center to make it 8-4 for Boston.

Game Notes

Boston has taken 10 of 17 meetings over Baltimore this year, and has split eight matchups in the Charm City...Ellsbury extended his MLB-record hitting streak against the Orioles to 34 games dating back to April of 2009...Guerrero, the all-time leader in career hits by a Dominican-born player, finished 3-for-5...Papelbon threw 28 pitches in the ninth, 21 for strikes.