Perez hits 3-run HR in 9th, Royals beat Rays 5-4

Kansas City Royals' Eric Hosmer (35) and Jarrod Dyson, center, celebrate after scoring on a three-run homer by Salvador Perez (13) off Tampa Bay Rays reliever Kirby Yates during the ninth inning of a baseball game Wednesday, July 9, 2014 in St. Petersburg, Fla. The Royals beat the Rays 5-4. (AP Photo/Steve Nesius)

ST. PETERSBURG, Fla. (AP) — Salvador Perez gave the Royals a late lift Wednesday night heading into a key midseason series.

Perez hit a go-ahead, three-run homer in the ninth inning and Kansas City beat Tampa Bay 5-4 to take two of three from the Rays.

The second-place Royals return home Thursday night to begin a four-game series against AL Central-leading Detroit, which has a 4 1/2-game lead.

“That was a huge win for us,” Kansas City manager Ned Yost said. “That’s the difference between 4 1/2 games back compared to 5 1/2 games back. Definitely nice to have a little momentum going home for the last four games before the All-Star break. It’s a lot better than the alternative.”

Kirby Yates (0-1), the fifth Tampa Bay reliever, entered with runners at the corners and gave up Perez’s one-out shot into the left-field corner.

Perez wasn’t sure if the drive would stay fair or even clear the low fence near the foul pole.

“As soon as the ball hit on the other side, good for us,” he said.

It’s been a big week for Perez, chosen Sunday to start at catcher for the American League in next week’s All-Star game.

All-Star outfielder Alex Gordon (sprained right wrist) and third baseman Mike Moustakas (flu) were not in Kansas City’s starting lineup. In addition, left-hander Jason Vargas was taken to the hospital for an appendectomy.

Gordon entered as a ninth-inning defensive replacement. He will have an MRI exam Thursday.

“I don’t think it’s anything serious,” he said.

Kevin Kiermaier went 4 for 4 with a grand slam for the Rays.

Tampa Bay, which lost for the fourth time in 14 games, missed a chance to gain a game on AL East-leading Baltimore. The Rays remained nine games back of the Orioles in fourth place.

“It stings a little bit,” Yates said. “It’s a game we could have won and we needed to win. Obviously, it doesn’t feel good. It’s a situation where you let your team down, but there’s nothing I can do about it now.”

After starter Yordano Ventura walked light-hitting Jose Molina to load the bases with two outs in the fourth, Kiermaier sent a shot into the right-field stands to give Tampa Bay a 4-2 lead.

Eric Hosmer hit a first-pitch solo homer with two outs in the first off Alex Cobb that put the Royals up 1-0. It was the first time Cobb pitched against Kansas City since being struck near the right ear June 15 last year by a liner hit by Hosmer.

Cobb, sidelined for two months due to problems that included a concussion and symptoms of vertigo, allowed two runs and six hits in 6 2-3 innings.

Ventura gave up four runs, five hits and four walks in five innings. He struck out five.

The Royals loaded the bases with no outs in the fourth, but scored just once to take a 2-0 lead on Raul Ibanez’s grounder. Kansas City failed to score with the bases loaded and two outs in the seventh when reliever Grant Balfour got a pop fly from Perez.