SAN FRANCISCO -- The San Francisco Giants wanted nothing more than to clinch the NL West the first chance they got and enjoy a relaxing weekend.
San Diego came out swinging and denied its division rival an immediate champagne party.
Adrian Gonzalez hit a three-run homer, Ryan Ludwick and Matt Stairs also connected, and the Padres put San Francisco's potential celebration on hold for at least a day with a dramatic 6-4 victory Friday night.
"Momentum is big, and for us to rally back from down six runs and make a game of it, you can flip a coin," San Francisco's Aaron Rowand said. "They won the first game, but we definitely gave them something to think about, that we're not going to let down. And they know that."
The first-place Giants need one more victory to capture their first division crown and playoff berth since 2003. San Diego pulled within one game of wild-card-leading Atlanta, which lost 11-5 to Philadelphia.
Clayton Richard (14-9) won for only the second time in seven starts and held down a Giants team that has hit 17 homers in its past eight games. Rowand connected for a pinch-hit, two-run shot in the sixth to chase Richard.
Ludwick hit a towering drive over the center-field wall leading off the second against Matt Cain (13-11), who surrendered a season-high three homers.
"Our mindset is just to go out and do it all over again," Gonzalez said. "We take absolutely no satisfaction with this win."
San Diego's offense came to life after managing just five runs and 17 hits in losing three of four at home to the Chicago Cubs before coming to the Bay Area. But the Padres, who led 6-0 early, had to hold off threats in the eighth and ninth.
"Yes We Cain!" posters were handed out on the night the pitcher celebrated his 26th birthday. But he didn't have it. Cain, the longest-tenured member of the Giants, had his start pushed up to go on regular rest for the potential clincher.
Next up for the Giants is Barry Zito on Saturday afternoon. The lefty is 1-7 with a 6.50 ERA over his past 10 games, nine starts, and is 3-7 in his career against the Padres.
"I'm not concerned about their mindset," Giants manager Bruce Bochy said. "We never assumed this was going to be easy."
San Diego snapped the Giants' four-game winning streak and scored six runs for the first time in 10 games since a 6-0 road win over the Dodgers on Sept. 21.
David Eckstein scored on a wild pitch in the fifth for the Padres, who are 6-1 at AT&T Park this year. They were unfazed by a sellout crowd of 42,409 orange-clad fans waving rally towels.
"This is like a playoff atmosphere, especially with all the Giants fans who are so into it," Padres closer Heath Bell said.
Richard beat the Giants for the fourth time in six starts this season. The left-hander allowed three runs and seven hits in 5 1/3 innings.
Cody Ross doubled with two outs in the sixth against Ryan Webb, putting runners on second and third and bringing Andres Torres to the plate as the tying run. Joe Thatcher came in to face Torres, who chopped an infield single about 15 feet down the third-base line to drive in Juan Uribe and cut San Diego's lead to 6-4.
Pinch-hitter Mike Fontenot led off the eighth with a single off Gonzalez's glove at first. Ross reached two outs later on an infield hit, and manager Bud Black turned to Bell to face Torres, who grounded out.
"It's a situation now where every out is super, super important," Black said. "We felt this was a game we had to have, so we used our guys."
Bell then worked the ninth for his 46th save in 49 chances, his sixth in seven tries going more than one inning. With Sanchez aboard on a leadoff walk, Aubrey Huff hit a deep fly to right that Will Venable caught nearly at the wall. Sanchez took off at contact (expecting the ball to come off the wall), rounded second and was doubled up. Bell walked to home and slapped hands with catcher Yorvit Torrealba. Buster Posey grounded out to end it.
"Obviously it would have been nice to see what happened if I had not done what I did in the ninth," Sanchez said.
The Padres won the first eight meetings between the rivals to start the season, but the Giants took three of four at Petco Park from Sept. 9 through 12.
"This group is not going to give in," Giants left fielder Pat Burrell said. "We're going to fight. If you had asked anybody in spring training if we would be up two with two to go, you'd take that. I know it's rough because we lost a game, but we're in good position."
Rowand had only two hits in 21 at-bats in September. This was his second career pinch-hit homer, both in 2010. He had the other July 26 against Florida.
Miguel Tejada drew a two-out, nine-pitch walk in the first before Gonzalez doubled. Tejada bolted home and came sliding in headfirst but was thrown out on a perfect sequence from right fielder Jose Guillen to second baseman Sanchez and then catcher Posey, who barely tagged Tejada.
Cain, who had won his previous four decisions, was done after four innings for his second-shortest outing this year.
Rowand homered for the first time since Aug. 11. ... The Giants are 7-30 this year when giving up six or more runs. ... Cain allowed three or more homers for just the fourth time in his career and six or more runs for the 16th time. ... Guillen had his 107th career outfield assist, 96 in RF. ... Torres, who missed only 11 games after his Sept. 12 emergency appendectomy, was chosen as this year's "Willie Mac" Award winner named for Hall of Famer Willie McCovey. ... Ross also doubled in the fifth to give him a 10-game hitting streak.