By losing, the Rays fell to 2-3 on their current 10-game road trip while moving to 12-14 on the season.
"I've seen so many times when he's given up two in the first or the second inning, and that's all the other team would get, so I was concerned at that point," said Rays manager Joe Maddon.
Matt Joyce's two-run homer staked the Rays to a 2-0 lead against Shields, who made his first start against the team that he made 217 starts for from 2006 through 2012 before getting traded to Kansas City in December.
Evan Longoria then walked with one out and moved to third on James Loney's double to right. Shields appeared to be on the ropes. But with a big inning just a base hit away, Shields struck out Yunel Escobar and Luke Scott to end the threat.
"I was really hoping we would get those other two points in the first," Maddon said. "At least one. At least come up with a three-spot, because we know he knows how to settle down. And he did. He started pitching after that. ... He settled into his thing, and we didn't have a whole lot of really well-struck balls after that."
Desmond Jennings, who led off the game with a single through the middle, pointed out that Shields did what Shields does best.
"He was mixing up his pitches," Jennings said. "He was Shields, you know. He's good. He throws every pitch for a strike. He throws four different pitches, five different pitches. So it's hard to sit on a pitch with him. And he's got the good changeup that he's always going to have. So it was different."
Shields allowed that Tuesday night's experience felt a a bit weird, but he managed to find "a little tunnel vision," and then it was "kind of game on."
"This is what I like to do," Shields said. "But it was definitely a lot of fun facing that team, a lot of good memories over there. It was a little weird seeing a Rays jersey across the field, but it was a good game tonight."
And a satisfying one as well.
"It's very satisfying," Shields said. "I know every one of those guys like the back of my hand over there, and I've got a lot of brothers on that team. I definitely wanted to win this game tonight."
Alex Cobb started for the Rays, and appeared up to the task of competing against his former teammate, finishing 5 2/3 innings unscathed and leading 2-0 at that point.
"Cobb's matching everything, 5 2/3 almost perfectly pitched game, and then it fell apart very quickly," Maddon said. "And that was unusual to see."
Eric Hosmer doubled to left to start Kansas City's two-out rally in the sixth. Lorenzo Cain singled him home before Mike Moustakas homered to right to give the Royals a 3-2 lead.
"That was the worst pitch of the game," said Cobb. "Just kind of laid a changeup in there, and he did what he should have with it."
Moustakas had not homered in 129 at-bats, a streak that dated back to Sept. 14.
Kansas City's offense continued to attack. Jeff Francoeur doubled to left and scored on Salvador Perez's single to center to push the lead to 4-2. Former Rays infielder Elliot Johnson added a single to center, minting the Royals' sixth consecutive hit while chasing Cobb.
"Walking off the mound, I think that's the most angry I've ever been after a game," Cobb said. "But you know, I felt like from pitch No. 1, I was going to be able to have a smooth, easy-sailing game, go as deep as I could. Out of nowhere, that happens, so I think feeling good and everything coming kind of easy, and then just coming to a screeching halt is the most difficult thing to deal with."
Shields complimented the work of the Royals' offense on an emotional night for the veteran right-hander.
"The guys had my back, they always do," Shields said. "That's what this team is all about. We're real resilient. We've had a couple losses, and we fought back hard tonight. I've said it before: We've got a lot of character on this team, and it showed again tonight."