Kaepernick threw for four touchdowns, two to Crabtree, who had 107 yards receiving. The defense rattled Tom Brady at times, but also yielded 443 yards passing in a sloppy contest between two of the league's more precise teams.
AFC East champion New England (10-4), which had won seven in a row, trailed 31-3 in the third quarter and lost for the first time at home in December in 21 games. The Patriots also had won 21 in a row in the second half of the schedule before San Francisco somehow regrouped late in a game it seemingly had clinched long before.
San Francisco forced four turnovers, matching the number of giveaways New England had at home all season.
But then the Niners began sleepwalking, and back came Brady and the Patriots on a 6-yard TD run by Danny Woodhead and a 1-yard dive by Brady. A 5-yard pass to Aaron Hernandez and Woodhead's 1-yard run with 12:13 remaining tied it.
And just like that, San Francisco went in front again.
Rookie LaMichael James broke free for a 62-yard kickoff return. On the next snap the third time the Niners would have a one-play TD drive Crabtree took a pass on the left side, spun and headed into the end zone.
New England turned over the ball on downs and Akers made his kick. Stephen Gostkowski added a 41-yarder for the Patriots with 38 seconds remaining, but they couldn't recover the onside kick.
San Francisco led 17-3 at the half. And they looked safe after Frank Gore picked up Kaepernick's third fumble and scored on a 9-yard run, followed by Crabtree's 27-yard score in a pinpoint pass from the second-year quarterback.
The defense set up both of San Francisco's TDs in the third.
Dashon Goldson returned Steven Ridley's fumble 66 yards to the New England 3 before Gore found the end zone. Defensive end Aldon Smith, known for his sacks, grabbed a pass out of Hernandez's hands for his first career interception. After he was tackled, Smith ran directly to the sideline and sat down on the 49ers' bench.
He was back up on his feet cheering the next play, when Crabtree broke free to make it 31-3.
But no one can relax against the Patriots.
Unlike a week ago, when the Patriots routed Houston, they fell behind quickly in the rain and ran only 10 snaps on their opening three series. San Francisco's fearsome pass rush was sharp then, and Brady was hit on the arm twice while trying to pass.
Even worse, his long throw on their third possession for Wes Welker was picked off by Carlos Rogers, who then slalomed his way on the wet turf toward the New England end zone. Only Brady stood in his way at the 5, and Rogers fell trying to elude him.
It was a key stop because Delanie Walker fumbled two plays later.
Earlier, Kaepernick accounted for 60 yards through the air on the 49ers' first drive. Randy Moss showed the kind of elusiveness that made him a record-setter in New England from 2007 until he was traded early in the 2010 by getting behind the secondary for a 24-yard TD.
His short celebration as he faced the crowd drew loud hoots.
Brady preventing Rogers from scoring was about the only highlight for the Patriots in the opening quarter, but the 49ers weren't any more effective beyond their scoring drive and a 38-yard run on a fake punt by Dashon Goldson. The slopfest included Akers' being wide left on a 39-yard field goal.
All this from teams ranked 1-2 in fewest giveaways.
When the Patriots finally got their usually unstoppable offense going, they used 16 plays and converted a fourth down. But they stumbled inside the 10 when Brady was sacked by Ray McDonald. Gostkowski made a 32-yard field goal.
San Francisco answered quickly, helped by a 35-yard pass interference call on Aqib Talib. Walker slipped behind a zone defense for a 34-yard TD pass from Kaepernick, making it 14-3.
Akers made a 20-yard field goal as the half ended, finishing a 15-play, 76-yard drive. The three points were the Patriots' fewest in a half all season, and they were outgained 249-113.
Of course, that turned around in the second half.
Aside from the players' mistakes, the game also was slowed by officiating confusion that led to several lengthy conferences. One delay took about 10 minutes to decide whether 49ers punt returner Ted Ginn Jr., muffed a second-quarter kick.
Online: http://pro32.ap.org/poll and http://twitter.com/APNFL
San Francisco 41, New England 34
San Francisco 7 10 14 10 41
New England 0 3 7 24 34
SF • Moss 24 pass from Kaepernick (Akers kick), 10:55.
NE • FG Gostkowski 32, 8:31.
SF • Walker 34 pass from Kaepernick (Akers kick), 6:59.
SF • FG Akers 20, :00.
SF • Gore 9 offensive fumble return (Akers kick), 10:38.
SF • Crabtree 27 pass from Kaepernick (Akers kick), 10:21.
NE • Woodhead 6 run (Gostkowski kick), 5:59.
NE • Brady 1 run (Gostkowski kick), 14:58.
NE • Hernandez 5 pass from Brady (Gostkowski kick), 12:13.
NE • Woodhead 1 run (Gostkowski kick), 6:43.
SF • Crabtree 38 pass from Kaepernick (Akers kick), 6:25.
SF • FG Akers 28, 1:56.
NE • FG Gostkowski 41, :38.
Attendance • 68,756.
First downs 19 32
Total Net Yards 383 520
Rushes-yards 39-180 24-95
Passing 203 425
Punt Returns 3-15 5-13
Kickoff Returns 6-154 5-107
Interceptions Ret. 2-59 1-0
Comp-Att-Int 14-25-1 36-65-2
Sacked-Yards Lost 1-13 3-18
Punts 5-56.6 5-45.6
Fumbles-Lost 6-1 2-2
Penalties-yards 6-88 8-73
Time of Possession 30:13 29:47
Rushing • San Francisco, Gore 21-83, James 8-31, Goldson 1-31, Kaepernick 7-28, Dixon 2-7. New England, Woodhead 12-61, Ridley 9-23, Brady 3-11.
Passing • San Francisco, Kaepernick 14-25-1-216. New England, Brady 36-65-2-443.
Receiving • San Francisco, Crabtree 7-107, Moss 2-36, Gore 2-34, Walker 2-29, V.Davis 1-10. New England, Lloyd 10-190, Hernandez 10-92, Welker 5-56, Woodhead 5-23, Branch 4-37, Hoomanawanui 1-41, Vereen 1-4.
Missed Field Goals • San Francisco, Akers 39 (WL).