San Francisco's top-ranked defense couldn't topple Drew Brees when it counted, but 49ers quarterback Alex Smith did.
Smith ran for one touchdown and threw for three more, including the game-winning 14-yard scoring pass to tight end Vernon Davis with nine seconds to play, to lift the 49ers to a stunning 36-32 victory over Brees and the visiting New Orleans Saints in Saturday's NFC divisional round.
Smith outdueled Brees in a frenzied finish that saw four touchdowns scored in the final 4:02 to send the No. 2-seeded 49ers (14-3) into the NFC Championship Game next weekend against either the Green Bay Packers or New York Giants.
San Francisco snapped the Saints' nine-game winning streak behind Smith, who directed touchdown drives of 80 and 85 yards after the Saints (14-4) had fought back from a 17-0 deficit to take their first lead with 4:02 to play.
Davis hauled in seven passes for 180 yards and two touchdowns, and had a huge 37-yard catch to set up a designed 28-yard quarterback sweep for a touchdown by Smith for a 29-24 lead with 2:11 to play.
Brees threw for 461 yards and four touchdowns, setting a postseason record with his third straight 400-yard game.
He connected with Darren Sproles on a 44-yard scoring pass with 4:02 remaining and fired a 66-yard scoring strike to tight end Jimmy Graham to put New Orleans back in front 32-29 with 1:37 to play.
That was more than enough time for Smith, who hit Davis for 47 yards to 49ers' 20-yard line with only 20 ticks remaining.
Instead of settling for a possible tying field goal, Smith found Davis in the end zone to cap the stirring finish and give San Francisco the victory in its first playoff game in nine years.
Sproles wound up with a postseason-record 14 receptions for 116 yards and a TD and Graham had five catches for 103 yards and two scores.
Smith threw for 299 yards, including a pair of first-quarter TD passes as San Francisco bolted to a 17-0 lead by by taking advantage of three of the Saints' five turnovers.
Brees directed a pair of second-quarter scoring drives, capping the first with a 14-yard pass to Graham and the second with a 25-yard strike down the right sideline to Marques Colston to cut the deficit to 17-14 at halftime.