The victory was Tampa Bay's 11th in 16 games and lifted the Rays, who have won four of their last five series, three games over .500 (19-16) this deep into a season for the first time in franchise history.
"Honestly, our guys really have a very good way about them right now. We're expecting to win on a nightly basis," manager Joe Maddon said. "We almost feel like if we can keep it close, we'll be able to do something at the end. Those are good feelings. That's how you get to play at the end of the year -- when you're able to keep games close and win them at the end somehow."
The Rays are doing it with improved pitching and defense, as well as timely hitting.
Shields (4-2) rebounded from the second-shortest outing of his career for his second shutout in his past three starts.
Thanks to some nice plays behind him, including Carl Crawford's diving catch in the gap to rob Mike Napoli of an extra-base hit in the third, Shields faced just 28 batters -- one over the minimum and a Rays record for a complete game.
"Spectacular," Maddon said. "Just totally in command."
Angels starter Jon Garland allowed no runs and four hits in eight innings. He walked three and struck out two before being replaced by Justin Speier (0-2), who gave up a leadoff single to B.J. Upton in the ninth.
Carlos Pena, who had two of Tampa Bay's hits off Garland, grounded to first base, moving Upton to second. Three pitches later, Longoria hit his fourth major league homer into the seats in left-center.
"I think it was just a sinker that he left up," said Longoria, who thought the ball was going to be caught short of the wall.
"I was pumped," the rookie added. "I was more pumped for Shields because I hate to see a guy pitch like that and get a loss."
Shields, who tossed a two-hitter to beat Boston 3-0 at Tropicana Field on April 27, struck out eight and walked none. He allowed seven runs and 10 hits in a 12-4 loss to the Red Sox at Fenway Park last weekend, throwing 98 pitches in just 3 2/3 innings.
This time, he only needed 70 pitches to get through the first seven innings, limiting the Angels to their only two baserunners of the night.
"He was aggressive early on. He wasn't messing around," Los Angeles manager Mike Scioscia said.
"I think I was more efficient today," Shields explained. "My first-pitch strikes were a little better. ... When I get ahead in the count early, I can get to my changeup a little quicker."
Garland allowed three walks and three singles over the same stretch. But only one of the runners got as far as second base, and the Angels helped their starter with a pair of double plays.
"Unfortunately we didn't score any runs for Gar," Speier said. "He pitched a heck of a game."
Los Angeles, already playing without injured infielders Chone Figgins, Howie Kendrick and Maicer Izturis, lost shortstop Aybar when he was hit by a pitch in the left pinkie finger leading off the fourth inning.
X-rays were negative, and the Angels said Aybar is day-to-day with a bone bruise.
- American Idol finalist Syesha Mercado, a native of nearby Sarasota, sang the national anthem.
- Figgins missed his fifth consecutive game for the Angels with a strained right hamstring. He took batting practice and did some running before the game, and manager Mike Scioscia said a decision on whether to place him on the disabled list will be made soon.
- After the game, Rays DH-OF Cliff Floyd (right knee surgery) was activated from the 15-day disabled list. Haynes was designated for assignment.