One inning earlier, the rookie center fielder prevented a San Diego rally by throwing out Mark Kotsay at home plate.
The hit left Perez with a .421 batting average (8-for-19). The throw gave him his fourth outfield assist, already tops among Giants outfielders, in just seven games.
Perez was recalled from Fresno on June 7 when center fielder and leadoff hitter Angel Pagan went on the disabled list. At the current rate, Perez likely will remain with the Giants even when Pagan recovers from his left hamstring injury and rejoins the active roster, which could be as soon as next week.
"He's been quite the sparkplug that we seem to have needed," said right-hander Sergio Romo, who ended the Giants' three-game losing streak by recording his 17th save. "He's showing us who he is and what he can do. And that's what you like to see out of a young guy like that."
Giants manager Bruce Bochy tried to remain cautious when asked how Pagan's return might affect Perez. "We'll cross that bridge when we get to it, but you have to like the things that he keeps doing," Bochy said. "He's doing all he can to stay here."
Bochy's description of Perez sounded as if he'd like to see more of the 26-year-old.
"He's a guy who I think can only get better," Bochy said. "He has a good eye at the plate, he gets great jumps on balls, and he's a great athlete."
All Perez can do is keep playing.
"I don't know, man," he said when asked whether he felt he has accomplished enough to remain in the Majors. "I just have to keep trying to help the team win and do anything I can on the field. They'll make their own decisions."
Perez decided the outcome after the Giants began the eighth inning trailing, 4-3. Buster Posey singled off Padres reliever Dale Thayer (0-3) to open San Francisco's half of the eighth. One out later, Brandon Belt's third hit, a double off the right-field wall, scored pinch-runner Andres Torres. After Nick Noonan drew an intentional walk, Joaquin Arias lined out. Perez then grounded a 3-2 pitch into right field, sending home Belt.
One swing earlier, Perez hit a howling line drive down the left-field line that carried foul. Quite often, such events seem to deflate even the best of hitters. But Perez simply sent Thayer's next pitch, a 93-mph fastball, scissoring past Padres second baseman Logan Forsythe.
Perez sensed what he would see from Thayer, having faced him during Monday's 13-inning marathon. "I had a good idea what he had -- sliders, a little sink ball," Perez said.
As if this were the NBA, the lead changed hands three times in a two-inning span. Gregor Blanco's two-out RBI single gave the Giants a 3-2 lead in the seventh inning before pinch-hitter Jesus Guzman's two-run homer in the eighth off Jeremy Affeldt put San Diego ahead.
This was a special victory for the Giants, since they were able to halt both the momentum of the National League's hottest team and their own free fall. The Giants' 5-3 loss Monday, which unfolded after they led, 3-1, left them hungry for a reversal.
"After last night, to have the lead and not win, we're not used to doing that a lot," right-hander Matt Cain said. "A lot of times when we have a lead, we finish them off. ... The guys stayed with it. I think that shows a lot as to what the guys have."
Cain demonstrated a lot himself. He continued his resurgence while striking out a season-high 10 in seven innings. Cain retired 15 Padres in a row, including eight on strikeouts, after Forsythe singled to begin the game. Nick Hundley's leadoff homer in the sixth inning ended Cain's spell, and Forsythe homered one out later. Those long balls erased the Giants' 2-0 lead and were the first homers Cain allowed since May 16 at Colorado, six starts ago. Nevertheless, Cain has recorded a 1.31 ERA in a span of three consecutive quality starts.
"Cain had probably more than we've seen in a long time, a wide assortment of pitches," Padres manager Bud Black said. "He was really mixing his pitches and we couldn't solve him. Then he left some pitches up [for home runs], and we put a little stress on him."
The Giants endured some stress earlier when shortstop Brandon Crawford bruised the index and middle fingers of his right hand when he slid into second base on an unsuccessful second-inning stolen-base attempt. X-rays showed no fracture, and Crawford hoped that he'll be able to rejoin the lineup after missing only Wednesday's series finale against the Padres.
Crawford's mishap, which forced him to depart after three innings, offset the return of second baseman Marco Scutaro, who played his first game since injuring his left pinkie last Tuesday. Scutaro, the Giants' leading hitter with a .335 average, collected a pair of infield hits in four at-bats.