Nelson Cruz scored from third on a wild pitch by Joel Peralta (2-3) with two outs in the eighth as the Rangers took a 4-3 lead. Peralta had replaced J.P Howell after the lefthander gave up consecutive singles to begin the inning.
Sean Rodriguez and Matt Joyce also homered for the Rays. Alex Cobb allowed three runs and four hits over 61/3 innings in his second career major league start.
Joyce, who entered with a major league-best .368 batting average, pulled Tampa Bay even at 3 on a two-out, two-run shot off Texas starter C.J. Wilson in the seventh. Longoria started the inning with an infield single.
Kyle Farnsworth pitched the ninth for his 10th save.
Wilson gave up three runs, three hits, four walks and struck out 10 in 62/3 innings. He took a one-hitter into the seventh.
The Rangers, who had won in three in a row, went ahead, 2-1, during the top of seventh on Ian Kinsler's run-scoring single off Cobb, who was recalled from triple-A Durham on Monday. Michael Young extended the lead later in the inning to 3-1 with an RBI single against Howell.
Adrian Beltre put the Rangers up, 1-0, with a third-inning RBI single.
Rodriguez, one day after making three errors at shortstop, tied it at 1 during the third on his second homer this season and first since April 5.
Wilson struck out five in a row after Rodriguez's shot, and made a barehanded grab on Justin Ruggiano's inning-ending grounder in the fifth. The lefthander was facing Tampa Bay for the first time since Game 2 of last year's ALDS.
Rays 5, Rangers 4
Texas 001 000 210 – 4 7 0
Tampa Bay 001 000 22x – 5 5 2
Texas AB R H BI BB SO Avg.
Kinsler dh 3 1 1 1 2 0 .241
A.Blanco ss 3 0 0 0 1 1 .240
b-Andrus ph-ss 1 0 0 0 0 0 .267