ST. PETERSBURG — You don't hear much talk about taking things one game at a time around the Tampa Bay clubhouse these days. The Rays have dug themselves such a hole that they can't afford to abide by that tired cliché' anymore.

It's all about winning series now, and the surging Rays were in position to win another one, their fourth straight, Wednesday night until the bullpen let the opportunity slip away in the ninth inning.

Salvador Perez, facing Kirby Yates (0-1), drove a towering three-run homer over the left-field wall and into the 162 Landing area to alter the outcome in what proved to be a 5-4 Kansas City Royals victory.

The loss, coming on the heels of series victories over Baltimore, the Yankees and Detroit, was the second in three games against the Royals but only the third for the Rays in their last 12 games overall.

Worse, though, was the fact it cost the Rays a chance to gain ground on the AL East division-leading Orioles, who dropped a 6-2 decision to the Nationals at home on Wednesday night.

The loss also wiped out the good feeling left behind by what may have been rookie Kevin Kiermaier's biggest night yet as a major-leaguer, a 4-for-4 outing at the plate that included his first career grand slam.

The grand slam was Kiermaier's eighth home run of the year and, coming in the fourth inning, it wiped out a 2-0 Royals lead and seemingly set the stage for Rays starter Alex Cobb to win his third straight game.

“Great night for him, wonderful night, and that's what we have to have — everybody contributing — if we're going to do get back into this, and we will,'' Rays manager Joe Maddon said. “But we left too many men on base tonight.''

The Rays, who pounded out eight hits, including four against hard-throwing starter Yordano Ventura, and drew seven walks, left 19 runners on and were just 1-for-9 with runners in scoring position.

The loss was as much the result of the work of Joel Peralta as it was Yates. After Grant Balfour, Jake McGee and Brad Boxberger combined to work 11⁄3 innings in relief, Peralta came in for the ninth.

He wasn't right from the beginning, though, allowing a leadoff single to Jarrod Dyson, who stole second and then third ahead of the walk he issued to Eric Hosmer after striking out Lorenzo Cain.

“I felt really good about Peralta in that moment,'' Maddon said. “He's been really good against lefties, and you had Dyson and then Cain there for them and so I felt good about it.''

Cobb was making his first start against the Royals since he took a line drive to the right ear off the bat of Hosmer on June 15, 2013, and unlike Yates or Peralta, he was locked in from the beginning.

In fact, he may have been too locked in. He threw nothing but strikes to the first two batters, striking out both on three pitches, but Hosmer hit Cobb's seventh pitch, another strike, over the right-field wall for a 1-0 Royals lead.

Cobb's second inning started out in completely opposite fashion. He walked Omar Infante on four pitches to start that frame, then fell behind Billy Butler before inducing him to ground out.

Cobb retired the next two batters he faced to end that mild threat, and he worked his way out of a far worse predicament two innings later after allowing the Royals to take a 2-0 lead.

“I liked what he did out there,'' Maddon said of Cobb, who was seeking his third straight victory. “Strikeouts were all over the place and he was getting a lot of ground balls.''

The Rays finally responded offensively in their half the fourth, which started with Evan Longoria grounding a sharp lead-off single back up the middle and James Loney working Ventura for a walk.

Brandon Guyer and Rodriguez followed with hard line-outs to left, but Ventura walked Jose Molina to load the bases.

That brought Kiermaier to the plate, and after falling behind 0-2 in the count, he quickly bounced back, drilling a 1-2 pitch over the wall in right center for his first career grand slam and a 4-2 Rays lead.

The grand slam was the first for the Rays since June 22 of last year, when Wil Myers hit his first career home run off of C.C. Sabathia in his sixth major league game, an eventual 7-5 loss to the Yankees.