Perez launched a two-run shot in the first inning, handing the Royals a 4-0 lead, but the Nationals scored the next four runs to tie the score.
Eric Hosmer drew an eight-inning walk from Craig Stammen (7-6), Billy Butler singled and Mike Moustakas coaxed another base-on-balls to load the bases. That brought up Perez, whose infield hit to short drove in Hosmer with the go-ahead run.
David Lough followed with another RBI single for Kansas City, which broke a seven-game losing streak.
Kelvin Herrera (5-6) notched the decision and Greg Holland nailed down the win with his 35th save.
Video of Victoria’s Secret models trying to 'twerk' hits Instagram
Ohio crash that killed two caught on camera [VIDEO]