SAN FRANCISCO — Victory in hand, the 49ers' locker room erupted in celebration. Players cheered, pumped their fists and exchanged high-fives. Minnesota had beaten Green Bay.

In a strange and uplifting epilogue to the Niners' 27-13 win over the Arizona Cardinals on Sunday, the team collectively watched the end of the Packers-Vikings game on TV monitors in the locker room, seeing their NFC West-clinching victory morph into something bigger — a first-round bye in the postseason.

"This is meant for us!" running back Frank Gore yelled into the din after Vikings kicker Blair Walsh delivered his team a win with a 29-yard field goal as time expired.

As the day began, San Francisco was being fitted for the No. 3 seed in the NFC and a first-round home game next weekend. Green Bay's loss elevated the 49ers to the No. 2 seed, meaning Jim Harbaugh's team can sit out the first round as spectators before hosting the No. 3, No. 4 or No. 5 seed at 5 p.m. on Saturday, Jan. 12.

"It's a little nerve-wracking watching them play," 49ers quarterback Colin Kaepernick said. "We would have been a lot better off if we handled business (at Seattle) last week and kept the ball in our court and made sure we could handle business ourselves."

The Niners might have taken the hard route, but they secured the bye. It not only gives them one less chance at getting eliminated. It offers an extra week of rest for star defensive lineman Justin Smith, who missed his second game with a torn triceps tendon.

Even Sunday's game at Candlestick Park had its moment of agitation as Arizona staked a 6-0 lead and the 49ers bumbled around on offense. But Kaepernick and Michael Crabtree got hot, the defense got tough and the Cardinals ended up looking as inept as everyone had expected.

The 49ers have captured consecutive division titles for the first time since 1994-95.

San Francisco scored 27 straight points after falling behind by two field goals, and wound up with 407 yards of total offense. Much of it came on the Kaepernick-to-Crabtree connection. The wide receiver caught eight passes for a career-high 172 yards and two touchdowns, picking up the slack with Mario Manningham on injured reserve with a knee injury and tight end Vernon Davis, who suffered a concussion last week, being limited to one catch.

Crabtree finished the regular season with 1,105 yards, his first 1,000-yard season in the NFL.

"He's a playmaker," Kaepernick said. "You put the ball in his hands and he's going to do something with it."

The second-year QB is a playmaker, too. After getting off to a slow start, Kaepernick repeatedly bought time with his feet, but had the patience to pass up running yards for throws to open receivers. Both of Crabtree's touchdowns came with cornerback Patrick Peterson in coverage. The first, a 49-yarder on a deep pass, gave the 49ers their first lead midway through the second quarter. The latter, with 5:58 left in the third quarter, was a 7-yarder on a perfect throw from Kaepernick, just over Peterson's reaching hand.

"I really have to say that he's a good player, at least in the games that he's played against us,' Arizona coach Ken Whisenhunt said. "But Patrick hasn't played very well against him, either. It seems like we can't tackle that guy."

The 49ers went up 17-6 on Crabtree's second score, and added another touchdown early in the fourth quarter on Frank Gore's 2-yard touchdown plunge. Gore had been quiet to that point but gained 32 yards on six carries during the drive.

The defense closed out from there. Safety Donte Whitner ended one Cardinals drive in the fourth quarter by recovering Michael Floyd's fumble (defensive end Ray McDonald had stripped it), and cornerback Tarell Brown thwarted Arizona's next possession with an interception.

Playing behind Brian Hoyer, who was making his first NFL start at quarterback, the Cardinals surprised San Francisco by moving the ball effectively early on. They gained 129 yards in the first quarter, but just 133 over the final three — and most of that came on a meaningless late drive that netted Arizona a touchdown on Hoyer's 37-yard pass to Floyd.

"He's young. So he was staring down receivers," Brown said of Hoyer. "We just had to get a feel for him, and anytime you get a feel for a quarterback like that, all you can do is go out there and make plays."

Certainly, the victory exposed some of the 49ers' flaws as they head into the postseason. This is a team that has trouble out of the starting gate. Davis has receded into the background, and kicker David Akers continues to struggle; he missed two field goals Sunday.

But confidence is running high as the Niners take aim at another playoff run, a year after falling in overtime to the eventual-champion Giants in the NFC championship game.

"The Western Division champions, that means a lot to us and to our players," Harbaugh said. "And I congratulate them for getting that done. And maybe arguably the best division in football. And it gives you a chance to now go for the big championship. That's all you can ask for is to have one more game."

You can reach Staff Writer Phil Barber at 521-5263 or phil.barber@pressdemocrat.com.