Updated

BALTIMORE (AP) — Evan Longoria homered, drove in two runs and scored twice, and the Tampa Bay Rays blew a four-run lead before rebounding to beat the Baltimore Orioles 5-4 on Wednesday.

Willy Aybar had two hits and an RBI for the Rays, who took two of three to improve their major league-leading road record to 31-17. Tampa Bay is 7-2 against Baltimore, including 5-1 at Camden Yards.

James Shields (8-9) got the win, despite allowing four runs and eight hits in 6 1-3 innings. The right-hander had lost eight of 10 decisions in 11 appearances since May 25.

Rafael Soriano worked the ninth for his 24th save in 26 tries. Less than 24 hours earlier, the All-Star reliever botched a save opportunity in an 11-10 loss.

Ty Wigginton hit his 16th homer and second in two games for Baltimore. The Orioles stranded six and went 0 for 9 with runners in scoring position.

Baltimore had the potential tying run at second base in the eighth, but pinch-runner Scott Moore was thrown out trying to advance on a one-out grounder to shortstop.

Tampa Bay used one hit and three walks to go up 5-4 in the sixth. B.J. Upton hit a leadoff single and Brad Bergesen (3-8) issued two straight one-out walks to load the bases before Jason Berken got Jason Bartlett to hit into a forceout at the plate. Berken then walked Longoria on a 3-2 pitch to force in a run.

Bergesen allowed five runs and nine hits, struck out seven and walked three in 5 1-3 innings. He kept the Orioles close after yielding four runs over the first three innings.

After Longoria's 14th homer put Tampa Bay up 1-0 in the first, the Rays got four hits in the second inning, including an RBI single by Reid Brignac and a run-scoring double by Ben Zobrist.

Aybar doubled in Longoria to make it 4-0 in the third.

Baltimore began its comeback with a three-run fourth. After Wigginton hit a two-run homer, Adam Jones singled and scored on a double by Jake Fox.

Luke Scott tied it with a run-scoring grounder in the fifth.

NOTES: Rays OF Carl Crawford (testicular contusion) was given the day off. ... Baltimore's Nick Markakis snapped an 0-for-14 skid with a fifth-inning double. ... The Rays didn't make an error in the series and have only three errors in their last 25 games. ... Tampa Bay's Carlos Pena went 0 for 5 and had only one hit in the series. ... Baltimore fortified its weary bullpen by activating LHP Mike Gonzalez off the disabled list and recalling LHP Troy Patton from Triple-A Norfolk, but neither got in the game.