Longoria put the Rays up 1-0 in the first inning with an RBI double and homered in the fourth for a 2-0 advantage.
The third baseman added a two-run double in the next frame to help the Rays sweep a three-game series from Texas and move one-half game in front of the New York Yankees atop the American League East.
B.J. Upton added a solo shot Matt Joyce drove in a pair of runs for the Rays, who won their fifth straight.
James Shields (11-11) was effective over seven innings, limiting the first-place Rangers to one earned run on four hits over seven innings, fanning six.
Rafael Soriano was called on to make his 35th save after Texas pulled to within two on Mitch Moreland's two-run, ninth-inning homer.
Rangers starter Derek Holland (2-2) lasted 4 1/3 innings, allowing five runs on six hits.