FOXBOROUGH, Mass. - Colin Kaepernick threw four touchdown passes in San Francisco's 41-34 win Sunday night over the turnover-prone New England Patriots.

Six days after the Patriots' 42-14 win over the Houston Texans, who had the NFL's best record, they were on the other end in another game against one of the league's top teams.

Kaepernick, making his fifth start after replacing Alex Smith as San Francisco's starting quarterback, threw scoring passes of 24 yards to Randy Moss, 34 yards to Delanie Walker, and to Michael Crabtree of 27 yards and 38 yards in the fourth quarter to break a 31-all tie.

With the win, the 49ers (10-3-1) clinched a playoff berth. They lead the NFC West over the second-place Seattle Seahawks (9-5), who beat the Buffalo Bills, 50-17, in Toronto earlier in the day.

The Patriots (10-4) have already clinched the AFC East title. They trail Houston (12-2) for the best record in the AFC. The Texans clinched the AFC South on Sunday with a 29-17 win over the Indianapolis Colts.

Before Sunday, the Patriots had won their last 20 December games at home since losing on Dec. 22, 2002.

New England entered the game ranked first in the NFL in points scored and yards gained but struggled against a 49ers defense that has allowed the fewest points and second fewest yards in the league.