Updated

Colin Kaepernick threw for 343 yards and three touchdowns, helping the San Francisco 49ers erase an early 14-point deficit and beat the St. Louis Rams 31-17 on Monday night.

Brandon Lloyd, Anquan Boldin and Michael Crabtree each caught a scoring pass for the 49ers (4-2), who have won three in a row. Ahmad Brooks and Dan Skuta had two sacks apiece for a stifling defense that sacked Austin Davis five times and permitted one first down on St. Louis' first six possessions of the second half.

The Rams (1-4) had 151 yards and a 14-0 lead after the first quarter on Benny Cunningham's 1-yard run and a 22-yard touchdown pass from Davis to Lance Kendricks.