"We had to win this ballgame and the manner in which we did it was just exciting," Royals manager Ned Yost said.
Ervin Santana (9-9) and the Royals moved up on the two teams ahead them in the race for the second AL wild-card spot, with the Yankees and Orioles both losing. Tampa Bay currently holds that final playoff position.
Greg Holland closed for his 43rd save, helped by an outstanding defensive play that shut down the AL Central leaders.
Fielder walked to open the ninth, and the Tigers' burly first baseman tried to score from first on Omar Infante's two-out double.
Gold Glover Alex Gordon made a strong throw from the left-field corner to Alcides Escobar, and the shortstop then made the relay throw to Perez.
Escobar's throw came in to Perez behind Fielder and the ball was shielded from the catcher's sight for about two seconds.
"I didn't see the ball," Perez said. "I just put my glove down and got the short hop and tagged him."
Escobar couldn't believe Perez's play.
"Unbelievable!" Escobar said. "That game was one of the best games I've ever played in in my career."
Detroit manager Jim Leyland agreed with third base coach Tom Brookens' decision to send Fielder.
"Really, they executed that play to perfection," Leyland said. "The only thing was, when I saw the throw coming in, I thought he might get a bad hop, but he made a terrific
pick of that ball, and tag."
Eric Hosmer had an RBI triple in the first for the Royals. He was thrown out at the plate on a grounder.
Santana (9-9) won for the first time since Aug. 4, outpitching Doug Fister (12-9). He allowed five hits in 6 2/3 innings, walking one and striking out five.
"Everything was working pretty good," Santana said. "I threw a lot of strikes and most of the time ahead in the count. That was the key."
Miguel Cabrera made a bid to put Detroit ahead with two outs and a runner on in the sixth, but Gordon caught his long drive to left-center at the fence.
Gordon lined a single on Fister's first pitch of the game, and he scored on Hosmer's one-out triple.
Royals second baseman Emilio Bonifacio was ejected by first base umpire James Hoye after being picked off first base by Fister for the final out of the third.
Chris Getz, who is from the Detroit suburb of Grosse Pointe, took over at second base for Kansas City.
Kansas City trainer Nick Kenney came out to check on Santana after he was hit by Andy Dirks' liner in the second. Santana recovered to throw Dirks out at first. Santana ultimately threw a couple of warmup pitches and continued. ... The Royals are 10-8 against the Tigers this season, clinching the season series with one game left. ... In Sunday's series finale, Detroit's Max Scherzer (19-3, 3.01) will go for his 20th win against Kansas City RHP Jeremy Guthrie (14-10, 4.11).