ST. PETERSBURG -- Don't get James Shields angry.

Getting knocked out by the Red Sox on Saturday after just 3 2/3 innings did not sit well with the right-hander, who took the mound on Friday night looking to return to the form he'd shown when he pitched a two-hit shutout against the Red Sox at Tropicana Field.

And he pulled it off -- with a little help from Evan Longoria.

Shields pitched a complete-game one-hit shutout to lead the Rays to a 2-0 win over the Angels in front of a crowd of 12,039 at Tropicana Field. The victory moved the Rays to 19-16 on the season and tied a club record for seven consecutive home wins.

Shields has "been surly," said manager Joe Maddon when asked about his pitcher's mood between starts. "He's been walking around like a sourpuss. He did not like what he did in Boston. He's very good, and he's very motivated."

Shields (4-2, 3.14 ERA) smiled when told of his manager's comments.

"I didn't like my last outing, it's not so fun. An outing like this is fun," said Shields, who was prepared to pitch the 10th inning after throwing just 92 pitches through nine. "I was on my game."

Thanks to Longoria's heroics in the bottom of the ninth, Shields did not have to pitch the 10th.

B.J. Upton singled off Los Angeles' Justin Speier to lead off the bottom of the ninth and moved to second when Carlos Pena grounded out to first. Longoria then launched a 1-1 pitch into the left-field stands to give the Rays the walk-off win.

"I think it was just a sinker he left up," said Longoria of the pitch he hit. "He's got that arm slot, and he just elevated a little bit. I was going around first, and I thought [the left fielder] was camped underneath it, and he looked up at it about halfway to second, and I said, 'Thank God.' I was pumped. But I'm more seriously pumped for Shields right now, because I hate to see a guy pitch like that and get a loss. It's a good feeling for him."

After the gem Shields twirled against the Red Sox on April 27, most fans would have had a hard time picturing him pitching an even better game in his next outing at Tropicana Field. Yet Shields ranked Friday night's effort as the best of his career.

"I think I was more efficient today," said Shields when asked to compare Friday night's performance with that effort against the Red Sox. "I think my first-pitch strikes were a lot better today. And when I can get ahead early, I can get to my changeup a little quicker. That's what happened today. I didn't have any walks today, which I'm pretty happy about, the first time all year. I think I was better today, definitely."

Shields is the first pitcher to throw two shutouts this season, and he now ranks second in the Major Leagues in complete games, trailing only Toronto's Roy Halladay, who has four. Shields' effort also produced the second complete-game one-hitter in club history, matching the accomplishment of Joe Kennedy at Detroit on May 2, 2003.

In his last two outings at home, Shields has thrown 18 consecutive scoreless innings while allowing just three hits.

"Shields was spectacular," Maddon said. "He had command from the first pitch to the last one. Totally commanded it and gave us a chance to win. It was a really well-pitched game."

Upton and Carl Crawford came to Shields' defense twice in the early going to aid the masterpiece.

Upton dove to his left to rob a base hit from Gary Matthews for the first out of the game. Crawford then stole at least a double from Mike Napoli when he dove to his left to snare his drive leading off the third.

"We made some amazing plays on defense," Maddon said. "The play by Carl is one of the better ones I've seen in this ballpark. Full speed, diving."

Added Shields: "I've been telling people from Day 1, this is one of the best -- if not the best -- outfields in the country. They made some outstanding plays today."

Jon Garland started for the Angels and matched goose eggs with Shields through eight innings before Speier started the ninth.

"Jon pitched a terrific game, but you know, Shields really pitched well for those guys," Angels manager Mike Scioscia said. "He got a big play in left field from Crawford. As the game went on, the play got bigger and bigger. Jon matched him pitch for pitch, and I really liked his stuff. I thought his command got better as the game went on. ... Good game for him, and unfortunately, we couldn't get some runs to take advantage of it."