BALTIMORE -- Rays manager Joe Maddon constantly reminds his team not to just try to belt home runs. Tampa Bay came into Thursday's game ranked fifth in the American League in homers, but Maddon always tells the Rays to work on hitting the ball on the ground and on a line and not just in the air.

But putting the ball in the air still works nicely on certain occasions -- like Thursday night, when the Rays got homers from B.J. Upton, Josh Wilson and Akinori Iwamura. That power display helped the Rays rally from two early deficits and pull out an 8-6 victory over the Orioles before 17,546 fans at Camden Yards, completing a three-game sweep.

The victory gave the Rays (54-80) their first three-game road sweep since Aug. 12-14, 2005, against the Indians, and handed the Orioles (58-74) their ninth straight loss. In addition, it wrapped up Baltimore's worst homestand (1-9) in team history of 10 games or more.

This was the first time the Rays have swept a series in Baltimore since their first time in the city, in 1998, when they took a four-game series. It's also the first road sweep of any series for Tampa Bay since that August 2005 set in Cleveland.

Maddon said that while hitting three homers was nice, he just likes how his team is working at the plate in recent games.

"Pitchers throw home runs, hitters don't hit them," Maddon said. "Just working better at-bats is [important]. If the ball's not in a certain spot, you can't hit it out anyway. If you go up there and work a good at-bat, you can hit them once in a while. I just overall like the quality of the at-bats, they've gotten better."

The good at-bats and timely hitting are a big reason the Rays have won seven of their last nine games. They've scored 65 runs in their last seven games, averaging over nine runs per contest. Tampa Bay scored 28 runs in sweeping the three-game series.

Wilson started the power surge with his first Major League homer, a line shot off Orioles starter Jeremy Guthrie (7-5) that just made it over the center-field fence. The Orioles had taken a 3-0 lead off Rays starter Scott Kazmir on a Nick Markakis three-run homer in the first, but Wilson's homer started the comeback in the third.

"I've never hit a home run to center field," Wilson said. "Coming off the bat, I'm just hoping for a double. For that ball to get out, I definitely surprised myself."

Wilson, who also made some nice defensive plays, cut the lead to 3-1 with the homer. Later in the inning, Upton lined a three-run homer to give the Rays a brief 4-3 lead.

"Upton's [homer] totally turned the momentum of that game around and gave us a much better feel about it," Maddon said.

Kevin Millar answered with a two-run homer off Kazmir in the bottom of the third for a 5-4 Orioles lead. But the ace left-hander hung in and threw two scoreless innings to finish his night.

He gave up five runs on seven hits in five innings, but got the win when Josh Paul's squeeze bunt tied it in the fourth, and Carl Crawford's single gave the Rays a 6-5 lead in the sixth. It wasn't Kazmir's best night, but he improved to 11-8, a career high for victories.

"It just wasn't there," Kazmir said. "I just had to battle pretty much the whole entire game. You're going to have days like this. You just have to battle through it. I'm just glad that my teammates ... picked me up."

The Rays got a lot of help from several places. Iwamura added an insurance solo homer in the eighth. Pinch-hitter Greg Norton came through again off the bench, lining a ninth-inning sacrifice fly for an 8-5 lead.

Wilson finished with a team-high three hits. Crawford went 2-for-5 and has 48 hits this month, a new club record. Delmon Young also added two hits. The Rays left nine on base, but went 3-for-9 with runners in scoring position and helped their cause by turning two timely double plays.

Tampa Bay's bullpen turned in another strong effort to back up Kazmir. Scott Dohmann threw two scoreless innings, and Dan Wheeler blanked the Orioles in the eighth. Al Reyes struggled a little in the ninth, giving up a run on two hits, but hung on for his 22nd save.

Playing good baseball, the Rays now head to New York to meet the hot Yankees. The Orioles, however, go to Boston on a long losing streak and a lot of frustration.

"We had some chances to do some things and blow it open and we didn't," said Orioles manager Dave Trembley. "It's just been a terrible week, but there's nothing you can do about it now."