Updated

A subject of trade rumors before the deadline, the Tampa Bay Rays decided to hold onto a struggling James Shields.

Shields has since turned his season around.

Shields won his fourth straight decision and Jose Lobaton hit a solo homer as the Tampa Bay Rays downed the Kansas City Royals, 5-3, in the rubber match of a three-game set.

Shields (12-7) fanned seven and surrendered three runs on five hits and a walk in 7 2/3 innings for the Rays, who have won five of their last six games. Shields has 34 strikeouts and a 2.15 ERA during his winning streak.

"I was mixing my pitches pretty well," Shields said. "Overall I kept them off balance."

The right-hander was 1-3 with a 6.15 ERA in a seven-start stretch before the deadline.

B.J. Upton tallied two hits and a run scored, while Ben Zobrist, Jeff Keppinger and Ryan Roberts added an RBI apiece.

Luis Mendoza (7-9) allowed two runs on five hits and four walks over 4 1/3 frames for Kansas City, which had won 14 of its last 21 games coming in.

The Royals struck first in the second inning when Jeff Francoeur hit a two-out RBI single to center field, but Tampa Bay plated a pair in the third and a run in each of the sixth and seventh innings to take the lead.

Upton and Matt Joyce hit back-to-back one-out singles in the third before Evan Longoria was hit by a pitch to load the bases. Zobrist lifted a sacrifice fly to left field, which scored Upton, before Joyce came home on Keppinger's single to center field.

Roberts ripped an RBI double in the sixth and Zobrist smacked a run-scoring double in the seventh for a 4-1 Tampa Bay edge.

The Royals battled back and pushed across two in the eighth to make it a one- run game as Alcides Escobar belted an RBI triple and Alex Gordon stroked a run-scoring single.

But the Rays got a run back in the home half as Lobaton launched a leadoff homer to dead center field, increasing Tampa Bay's cushion to 5-3, and Fernando Rodney worked a 1-2-3 ninth to notch his 39th save of the season.

"With Shields on the mound, you know you can't give him too much leeway," Royals manager Ned Yost said. "The tack on runs in the sixth, seventh and eighth did us in."

Game Notes

Tampa Bay was 1-for-13 with runners in scoring position and left 10 men on base, while Kansas City finished 2-for-4 with RISP and stranded four ... Lobaton's long ball was the second of his career.