ST. LOUIS — Colin Kaepernick and the San Francisco 49ers answered St. Louis' fast start with a big finish.
Kaepernick threw for 343 yards and three touchdowns, helping the 49ers erase an early 14-point deficit and beat the 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.
"Our receivers did a great job today," Kaepernick said. "Our offensive line did a great job, protecting us and giving us time."
Kaepernick found Boldin zipping across the end zone for an 11-yard touchdown pass, capping a go-ahead 80-yard drive to start the second half. As the Niners were taking the 17-14 lead, several fans in the upper deck unfurled a large banner above the videoboard on the opposite end of the stadium as part of ongoing protests about the Michael Brown shooting in suburban Ferguson in August.
San Francisco then added to its advantage when Kaepernick connected with Crabtree for a 32-yard score with 13 seconds left in the third.
The Rams had one last chance to tie the game, but Dontae Johnson returned an interception 20 yards for the clinching score with 53 seconds to go.
It was a disappointing conclusion for St. Louis, which had 151 yards and a 14-0 lead after the first quarter on Benny Cunningham's 1-yard run and a 22-yard touchdown reception for Lance Kendricks.
St. Louis wore throwback uniforms — royal blue and bright yellow — to honor its 1999 Super Bowl title team and represented that winning squad very well for a short time. Guard Adam Timmerman joined wide receivers Isaac Bruce and Torry Holt for an impromptu bob n' weave TD dance in the end zone at halftime.
The Rams haven't had a winning season since the Greatest Show on Turf petered out in 2003. They doubled their first-quarter scoring for the year with a start that mimicked their last home game when they led Dallas 21-0.
They lost that one 34-31, and this one was all San Francisco the rest of the way.
The 49ers scuffled to a 1-2 start coming off a third straight appearance in the NFC championship game, but have won 13 of their last 14 in October.
Davis was 18 for 36 for 205 yards. He threw for 300 yards each of the last two games with six touchdown passes.
Three of Davis' four interceptions have been returned for touchdowns, all in the fourth quarter at home.
The 49ers had four penalties before the end of their first possession, three accepted, and one the rest of the way. One of the early miscues, illegal contact on Eric Reid, handed the Rams a second first-and-goal on their opening drive capped by Cunningham's TD behind extra lineman Tim Barnes.
Rookie Tre Mason's first career carry was a 24-yarder that might have gone the distance had he not run into teammate Brian Quick. Three plays later, Kendricks got well behind the defense on a 22-yard catch that made it 14-0 late in the first.
The 49ers inched back on Phil Dawson's 54-yard field goal, his 10th in a row with four beyond midfield. They were backed up at their own 5 inside the two-minute warning but declined to play it safe and Lloyd whipped Janoris Jenkins in single coverage on an 80-yard touchdown catch with 14 seconds left in the half.
"We had Brandon Lloyd on a double move," Kaepernick said. "We liked the matchup. He did an amazing job."
Boldin made two third-down grabs on the go-ahead scoring drive in the third quarter, including one for 15 yards on 3rd-and-12 to the 20.
Ongoing protests over the death of Michael Brown made a quick appearance at the Edward Jones Dome during the second half. A banner reading "Rams fans know on and off the field black lives matter," was draped over the top of a jumbo videoboard in the north end zone during the 49ers' go-ahead drive and a few minutes later, about three-dozen protesters marched with their hands raised in an aisle just below the upper deck in the south end zone. Five police officers followed them.
The protests stem from the August shooting death of Brown, who was unarmed, by Ferguson police officer Darren Wilson.