The Rays won their second straight on the heels of a six-game losing streak and climbed within two games of Boston for the top spot in the American League East.
Myers had three of Tampa Bay's 11 hits and drove in four runs to make Alex Cobb's return to the mound a successful one.
Cobb (7-2) was hit in the head by a line drive on June 15 and had been on the disabled list since then. He was limited to 88 pitches over five innings Thursday, but picked up the win by giving up a lone run on three hits with six strikeouts.
Myers singled in a run in the third inning to create a 1-1 tie and the Rays then took the lead with a four-run fifth.
Myers had a two-run double in that frame and Longoria hit a two-run homer. Myers tacked on an RBI double in the ninth.
Joe Saunders (10-12) gave up five runs on seven hits in 4 1/3 to take the loss.
Iranian woman stops the execution of son's killer
Rosie O'Donnell unveils nearly 50-pound weight loss