Billy Butler had just grounded into a double play against Seattle reliever Yoervis Medina (4-4) when Moustakas legged out a double to center in the eighth. Perez followed with a single to left, and Moustakas had just enough time for a headfirst slide ahead of Endy Chavez's throw to home.
Luke Hochevar (4-2) got two outs earlier in the eighth to leave runners stranded on second and third, and Greg Holland pitched a perfect ninth for his 31st straight save and 38th on the year.
Perez also homered and finished with three hits for the Royals, who have won three straight and eight of their last 10 to climb back into AL wild-card contention. Alex Gordon also hit a solo shot and Billy Butler drove in a run for Kansas City.
Kyle Seager hit a two-run shot for the Mariners, who have lost three straight.
The Royals took the lead on the first pitch of the game, which Gordon sent sailing over the outfield wall for the 12th leadoff homer of his career. The shot broke a tie with David DeJesus and Willie Wilson for the most leadoff home runs in franchise history.
Perez made it 2-0 with his solo shot in the fourth inning, and the Royals manufactured another run in the fifth. Emilio Bonifacio followed up his base hit by swiping second, and then came home when Butler hit a grounder through the left side of the infield.
That was all Seattle starter Erasmo Ramirez allowed in 6 1-3 innings. After getting recalled from Triple-A Tacoma, Ramirez scattered seven hits and three walks while striking out three.
Bruce Chen was just as stingy for the Royals early in the game.
The soft-tossing left-hander allowed four weak singles through the first five innings before Franklin Gutierrez ripped a crisp base hit to lead off the sixth. Seager followed with his home run to right field, which cleared the visiting bullpen and landed deep in the seats.
Seattle tied the game up in the seventh inning. Royals reliever Kelvin Herrera gave up a pair of singles, and Brad Miller's groundout off relief pitcher Tim Collins knotted the game 3-all.
The Mariners threatened again when they put runners on second and third with one out against Collins in the eighth inning. Hochevar struck out Mike Zunino and got Chavez on a fly ball to center to end the inning, and walked off the field to a standing ovation.
Notes: The Mariners added LHP James Paxton, RHP Chance Ruffin, RHP Hector Noesi and INF Carlos Triunfel from Triple-A Tacoma before the game. They also added Triple-A hitting coach Howard Johnson to the staff. ... The Royals added RHPs Wade Davis and Louis Coleman from Class-A Wilmington, and LHP Donnie Joseph and INFs Johnny Giavotella, Pedro Ciriaco and Carlos Pena from Triple-A Omaha before the game. ... RHP Taijuan Walker starts for the Mariners on Wednesday. RHP Ervin Santana goes for KC.