Pena's meltdown cost Arizona half of its NL West lead. San Diego pulled within one game of the Diamondbacks with a 3-0 victory over Pittsburgh.
Pena (5-4) had not allowed a run in seven September outings before giving up a career-worst five runs in 2/3 of an inning.
"I don't know what happened," he said. "It's not my day."
It wasn't Arizona's day either. After the game, the club announced that third baseman Chad Tracy would undergo season-ending surgery on his right knee on Thursday.
Arizona manager Bob Melvin has used Brandon Lyon in the eighth inning for much of the season but said he went with Pena because he had been pitching well lately and had better numbers against some of the Giants.
"Tony was the guy who was hot and ready to go," Melvin said. "That wasn't a tough call. He's been so good for us all year. It just didn't work out this time."
The Diamondbacks took a 3½-game lead into play last Friday. The one-game edge is their smallest since Sept. 5.
"We obviously know the significance of that game right there," said Arizona ace Brandon Webb, who allowed three runs in six innings. "We had it in our grasp and lost it. It was a big game for us. But we'll come right back tomorrow and play hard."
For their part, the Giants didn't play like a team that came to town in last place, 17½ games behind Arizona. San Francisco showed plenty of pop without slugger Barry Bonds, sidelined with a sprained right big toe.
Brian Wilson pitched the ninth for his fourth save in four chances.
"They fought," Giants manager Bruce Bochy said. "I can't say enough about that. It's a tough pitcher and a tough ballclub. That's a great win."
Arizona led 5-3 when Pena opened the eighth by plunking one batter with a pitch and walking another before Winn hit an 0-2 offering 420 feet to the pavilion high above center field.
"Teams have come from behind on us," Winn said. "Right after they went ahead, it was nice we kept fighting."
Boos erupted as Winn circled the bases. One out later, pinch-hitter Nate Schierholtz doubled to center field and Feliz hit a 388-foot shot into the left-field seats.
"We've been waiting for an inning like that for quite a while," Bochy said. "It's pretty impressive to do it off a good pitcher."
Winn, who also had a sacrifice fly, drove in four runs for San Francisco, which rallied after its bullpen blew a 3-2 lead in the seventh.
"What was impressive was how we gave up the lead there and came right back and put a crooked number on the board," Bochy said.
San Francisco's Kevin Correia outpitched Webb in Correia's 25th big league start, and his sixth since joining the San Francisco rotation last month. Correia has not allowed more than two runs in a start this season.
The Giants led 3-1 with two outs in the sixth when Bochy lifted Correia after his 102nd pitch. Correia left with two runners on, and Brad Hennessey promptly walked the next two batters to make it 3-2. Steve Kline then came on and retired Stephen Drew on a pop foul to the catcher.
Correia allowed two runs and three hits in 5 2/3 innings. He walked five and struck out six.
Webb had a 42-inning scoreless streak this season, but it took the Giants only three batters to push across a run. Leadoff batter Dave Roberts tripled down the right-field line and scored on Winn's one-out sacrifice fly to left.
The Giants loaded the bases with no outs in the fourth. Feliz drove in a run with a fielder's choice grounder to shortstop and Daniel Ortmeier added an RBI single to make it 3-1.
Webb escaped further damage when he induced Omar Vizquel to ground into a double play.
- Webb drew his first walk of the season, in 75 plate appearances, against Correia in the second.
- Reynolds struck out in the second for his 115th strikeout in 324 at-bats.
- Arizona dropped to 71-95 all-time against the Giants, and 35-47 in Phoenix.