With the win, the Rays improved to 38-35 on the season and 2-2 on the current road trip, which finishes with three more games in New York. The Rays are now just 1 1/2 games behind the third-place Yankees in the American League East.
Longoria's big game began with a sacrifice fly in the third that put the Rays up, 3-0, and gave him 500 career RBIs. He then gave the Rays a four-run lead with his 15th homer of the season, driving Andy Pettitte's first pitch of the sixth into the right-field stands. Finally, he led off the eighth with a solo blast off Joba Chamberlain, giving him the 12th multihomer game of his career and putting the Rays up, 6-3.
Until Thursday night, Pettitte had ruled Longoria, who had just two hits in 21 career at-bats against the veteran left-hander.
"Felt good to put some of the woes I've had against Andy Pettitte behind me," Longoria said. "For the short term, at least. He's pretty much dominated me for a long time. Tonight was probably one of the few times when he's thrown balls over the plate for me to hit.
"He's made some pretty good pitches on me, so as a team I thought we did a really good job against him, laying off some of his pitches. In the past we've swung at some of those good back-door sliders and cutters -- kind of let him have his way with us. So tonight was a great start for the series, and [it was] good to see us have some good at-bats."
The fact that Longoria's home runs went to right field in a leading indicator that his potent bat is locked in.
"That's what I want to do," he said. "Just kind of be gap-to-gap and hit the ball the other way. This is a great place to hit. I think a lot of hitters like coming here when they're on the road. It kind of gives you a little piece of mind that if you hit a good one, it's going to go out of the park. The Trop is sometimes a dead zone in center and right field, so we hit some balls good."
Pettitte lost his second consecutive start and fell to 2-5 with a 5.13 ERA in his last eight starts after winning his first three.
"He just got some balls in the middle of the plate, and he didn't miss them," Yankees manager Joe Girardi said. "[Yankees pitching coach] Larry [Rothschild] talked about -- after about four or five innings -- he said he didn't really make a ton of mistakes, but the ones he made, they really capitalized on. When he got a ball in the middle of the plate, they hit it."
Meanwhile, Moore looked more like the Moore who began the season 8-0.
After losing his first three starts of June, Moore pitched five scoreless frames to start the game before encountering trouble in the sixth, when the Yankees loaded the bases with no outs.
"Things were going well until the sixth inning. That was kind of the make-or-break-type moment, where it's either going to be a five-run inning, you know, Robby Cano up, bases loaded, no outs," Moore said, "or you can keep the team in the game, like we were able to."
Former Rays shortstop Reid Brignac scored from third on a wild pitch, Cano added a sacrifice fly and Jayson Nix scored on Travis Hafner's groundout to shortstop to cut the Rays' lead to one run. But the damage could have been worse.
Moore credited catcher Jose Lobaton for helping him through the outing.
"I don't feel like there were many pitches that [Lobaton called] where I didn't already have the grip [for the pitch he called]," he said. "That was pretty important, the fact that we were on the same page."
Tampa Bay's offense banged out 14 hits, including back-to-back doubles by Desmond Jennings and Sean Rodriguez off Pettitte in the seventh that gave the Rays a little cushion after the Yankees narrowed the gap in the sixth.
"Yeah, Jennings and Rodriguez took the heat off a little bit," manager Joe Maddon said.
Yunel Escobar added a two-run homer to center field off Boone Logan in the eighth that put the game on ice at 8-3.
The Rays are now 4-3 against the Yankees this season and seemingly out of the slump they had been in since last week.
"That's the way it's going to be, folks," Maddon said. "It's going to be the roller-coaster AL East all summer. It just is. We need to get back closer, obviously, but I really can see this bunching kind of effect [in the standings] the entire year."