Kirby Yates (0-1), the fifth Tampa Bay reliever, entered with runners on first and third with one out and gave up Perez's towering shot into the left-field corner.
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.
Aaron Crow (4-1) pitched a scoreless eighth for the win. Greg Holland got three outs for his 24th save.
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.