Buster Posey homered and the Giants finally got it done -- on their third try against the Padres this weekend -- to capture their first division crown and playoff berth since 2003.
San Francisco will host the wild-card Atlanta Braves starting Thursday at AT&T Park, with ace Tim Lincecum well rested to go in Game 1. The Braves beat the Phillies 8-7 earlier in the day, extending manager Bobby Cox's farewell season.
Two NL playoff races came down to Game 162.
San Diego missed a chance to force a Monday playoff with the Giants at Petco Park to decide the NL West winner. The loser of that would have flown to Atlanta to determine the wild card had there been a three-way tie.
Pablo Sandoval and other Giants players waved orange towels atop the Giants' dugout steps after closer Brian Wilson's first two pitches were strikes to Will Venable with two outs in the ninth.
When Venable struck out swinging, Posey ran out to Wilson and they jumped together at the mound. The rest of the Giants joined them and gray NL West champion shirts were quickly handed out.
The Giants then took a victory lap along the outfield warning track, slapping hands with fans leaning over the fence. Manager Bruce Bochy brought up the rear of the lap around the field, tipping his cap and waving it over and over again.
Padres players stayed put at the railing of their dugout watching the celebration in disappointment.
The pitching-rich Padres head home for a longer winter than they wanted knowing they blew quite an opportunity. San Diego led the division by 6 1/2 games before a 10-game losing streak from Aug. 26 to Sept. 5.
But manager Bud Black's team had trouble scoring all season, and that was its undoing at the end. The Padres managed only four hits Sunday and were shut out for the 12th time.
Sanchez (13-9) pitched into the sixth inning and gave up three hits while walking five. He contributed with his bat, too, hitting a triple off rookie Mat Latos (14-10) and scoring the game's first run in the third inning.
The Giants head back into the postseason a decidedly different team than when they last made it. Led by Barry Bonds, they lost in four games to Florida in the 2003 NL division series, a year after falling six outs shy of a World Series title and losing to the wild-card Angels in seven games.
In fact, San Francisco is back in the playoffs with a roster that looks nothing like the group that took the field on opening day. Posey was called up in late May and hit 18 homers to make a strong case for NL Rookie of the Year honors, and Pat Burrell revived his career after signing a minor league deal May 29 following his release by Tampa Bay. The bullpen features new faces, too. Mike Fontenot and Cody Ross also are newcomers.
Sanchez tripled and scored on a single by Freddy Sanchez, then Aubrey Huff followed with an RBI double.
Posey homered in the eighth for insurance.
Nearly two months after he guaranteed a three-game sweep of the Padres only to see San Francisco drop two of three, the left-handed Sanchez was the Giants' most reliable pitcher down the stretch. He went 4-1 with a 1.03 ERA over his last seven outings -- in July 2009, he threw a no-hitter against the visiting Padres.
Sanchez gave way to Santiago Casilla with none out in the sixth after allowing Adrian Gonalez's leadoff single and a walk to Ryan Ludwick. Casilla induced a double play and got an inning-ending groundout.
After a pair of strikeouts to start the seventh, Casilla allowed a single to Chris Denorfia and David Eckstein reached on the pitcher's error. Ramon Ramirez relieved and, in a fierce, nine-pitch at-bat, struck out a swinging Miguel Tejada on a full count.
Sergio Romo pitched a 1-2-3 eighth, pumping his arms after striking out Yorvit Torrealba for the third out.
Wilson finished it for his majors-best 48th save in 53 chances. He became the first Giants reliever since the save became an official statistic in 1969 to lead the majors. Wilson also matched Rod Beck for the San Francisco single-season record.
San Francisco's bullpen went its final six games and 24 innings without giving up an earned run.
The Giants advanced despite Sandoval's disappointing season and a career-worst five-start losing streak from Lincecum in August. The two-time reigning NL Cy Young Award winner bounced back in September. Barry Zito has been inconsistent -- his spot on the postseason roster isn't a given. Rookie Madison Bumgarner took on a key role in the rotation, won seven games and was unfazed by the responsibility.
The Padres lost for only the second time in nine games at AT&T Park this season. They went 12-6 against the Giants overall, winning the first eight meetings.
Notes: San Diego didn't score in the first two innings for the first time in the three games. ... The Giants reached the 3 million mark in attendance (3,037,443) for the ninth time in the ballpark's 11-year history, first time since 2007. ... Sanchez's triple was the first by a San Francisco pitcher since Matt Cain did it on Sept. 22 last year at Arizona. ... The 1996 Padres pulled off a three-game sweep at Dodger Stadium to end the season and win the division.