Shields went 7 2/3 innings, departing in the eighth after Johnny Giavotella's single and Alcides Escobar's two-out triple produced the Royals' second run. Left-hander Jake McGee took over and surrendered an RBI single to Alex Gordon to make it a one-run game at 4-3. Kyle Farnsworth replaced McGee and got Billy Butler to tap out.
Then Jose Lobaton boosted the Rays' edge to two runs by leading off the bottom half with a home run to center field against Aaron Crow. It was just the second homer of the rookie catcher's career.
Rays manager Joe Maddon claimed Lobaton just wanted another cup of ice cream, the reward he got from teammate Luke Scott after hitting his first big league homer earlier this year at Baltimore.
"I think he was really hungry by the end of the game and wanted some ice cream, and [he] hit the homer," Maddon said.
The Rays took the series, two games to one, and have won 13 of their last 16 games. Despite the loss, the Royals have won 10 of their last 15.
"These guys have got tremendous pitching -- starting pitching, bullpen. It's a team that you really don't want to come in and play, because they're coached well, they're managed well, they play the game right and their pitching is just phenomenal," Royals manager Ned Yost said.
"That being said, I thought we came in here and matched up pretty good in a three-game set."
The Royals lost the Monday night opener, 5-1, then won the second game on Tuesday night, 1-0, in 10 innings.
"Those guys in all three games were very tough," Escobar said. "[Jeremy] Hellickson the first day, [David] Price [Tuesday] and then Shields today -- those guys have good command on every pitch."
In the series, Rays pitchers gave up just 18 hits, 16 of them singles.
In Wednesday's finale, Royals right-hander Luis Mendoza, a winner in three of his previous four starts, was given a 1-0 lead in the second inning. His catcher, Salvador Perez, doubled off the left-field wall against Shields and scored on Mike Moustakas' single up the middle.
But the Rays countered with two runs in the third inning after loading the bases. B.J. Upton and Matt Joyce each singled and Evan Longoria was hit by a pitch. Right fielder Jeff Francoeur missed Ben Zobrist's foul fly in the Rays' bullpen, which likely only delayed the sacrifice fly that Zobrist subsequently lofted to left field. Jeff Keppinger followed with an RBI single that whizzed past Mendoza and went into center field.
That was all that Mendoza gave up, but control problems led to his removal in the fifth inning after issuing two walks.
"Just wasn't quite as sharp and command was off a little bit. And with the off-day [Thursday], we've got a full 'pen, and with Shields on the mound, you know you can't give 'em too much leeway," Yost said.
Mendoza was replaced by Louis Coleman, who induced a double-play grounder from Keppinger.
Though touched for just two runs, Mendoza gave up five hits, four walks, hit a batter and balked while making 81 pitches (43 strikes).
"I was behind all day," Mendoza said. "I had trouble with my command."
The Rays upped their lead to 3-1 with a run off Coleman in the sixth inning. Carlos Pena led off with a walk and scored on Ryan Roberts' double into the left-center-field gap. They added a fourth run in the seventh on Longoria's single, Zobrist's double and an error by Escobar.
Shields, meanwhile, was mowing down the Royals with precision. After Escobar's single in the third inning, he retired the next 12 batters before Moustakas drew a two-out walk in the seventh. But Shields recovered by making Francoeur his fifth strikeout victim.
"We came in here knowing we'd have our hands full, but I thought we did a great job of staying with it today and kind of coming back, but eventually we just ran out of innings," Francoeur said.
Oh, Lobaton got his ice cream.
"It was dulce de leche. It's not my favorite, but I ate it. The one in Baltimore was really good. I told Luke, 'Next time, please don't bring that again, I don't really like it.' But I was enjoying that moment," Lobaton said.
"If they're gonna give me ice cream for every homer, I'll take it!"