ARLINGTON, Texas (AP) -- Tampa Bay's offense has sputtered at times this season.
For some reason, though, the Rays haven't had any problems figuring out All-Star Matt Harrison.
Evan Longoria homered twice, Tampa Bay roughed up Harrison and the Rays beat the Texas Rangers 8-4 Wednesday night to snap a four-game losing streak.
The Rays have lost four 1-0 games since Aug. 5 - including one Tuesday night - but Tampa Bay found its stride against Harrison, who was coming off one of the best starts of his career.
''Our hitters have a decent history against him,'' Tampa Bay manager Joe Maddon said. ''I think it's one of those things where our guys see him pretty well. And perhaps he doesn't see them that well.''
Harrison (15-8) allowed seven runs and 12 hits in 5 1-3 innings.
The Rays have scored 14 runs with 26 hits in two starts against Harrison, who was looking to tie for the league lead in wins.
''We knew we had to jump out fast,'' said B.J. Upton, who hit a three-run homer in the second that put the Rays on top 6-0. ''We did that and kind of kept our foot down after that.''
After dropping the last two against the AL West-leading Rangers by one run, the Rays avoided the three-game sweep.
Tampa Bay had scored only 11 runs during their losing skid before breaking out for 16 hits against Texas.
Longoria hit a two-run homer in the first and a solo shot in the ninth. Elliot Johnson added a solo blast in the sixth.
Jeff Keppinger went 4 for 5 and Ben Zobrist had three hits for the Rays.
Jake McGee (5-2) pitched a perfect sixth and five Tampa Bay relievers combined for 4 1-3 scoreless innings.
Since July 19, the Rays' bullpen has posted a 0.76 ERA in 106 innings.
''Our 'pen was great once again,'' Maddon said. ''That's who we are.''
Josh Hamilton hit his 36th home run for Texas, a solo shot that brought Texas to 6-4 in the fifth.
The Rangers wrapped up a 7-3 homestand and have a 4 1/2-game lead over Oakland in the AL West.
''If we can continue to win series, we'll be right where we want to be,'' Texas manager Ron Washington said.
Harrison gave up seven runs and a career-high 14 hits in an 8-4 loss to the Rays on April 27. The left-hander struggled again against Tampa Bay on Wednesday night, giving up six runs and a pair of home runs by the second inning.
He took a no-hitter into the seventh and permitted two hits in eight shutout innings in his last outing Friday night against Minnesota.
''I put us in a big hole early in the game,'' Harrison said. ''I didn't give us a chance''
Zobrist's RBI double in the first snapped a 13-inning scoreless drought.
Longoria drove a 3-1 fastball from Harrison 409 feet to center. The two-run shot extended Tampa Bay's lead to 3-0. Longoria is 6 for 9 with three home runs against Harrison in the regular season.
In the second inning, Sam Fuld tripled with one out and Desmond Jennings walked to set the stage for Upton.
After Texas pitching coach Mike Maddux visited Harrison, Upton lined a fastball into the seats in left for his 16th home run of the season.
Johnson led off the sixth with a home run and Harrison was chased out of the game two batters later.
It was the first time Harrison allowed three home runs in a game since April 21, 2010 against Boston.
Texas' Mitch Moreland hit a two-run homer in the second, his 15th of the season. Nelson Cruz's RBI groundout got the Rangers to within 6-3.
Hamilton's 424-foot shot landed in the upper deck in right and gave him 112 RBIs, which leads the majors.
Rays starter Alex Cobb allowed eight hits and four runs in 4 2-3 innings.
Notes: Tampa Bay OF Matt Joyce, who left Tuesday's night's game with a strained left forearm, was not in the lineup. Maddon said Joyce might be available Thursday night at Toronto. ... Cruz was in the lineup after being hit in the left elbow Tuesday night. ... The Rays are 15-7 since Longoria came off the disabled list Aug. 7.