INGLEWOOD, Calif. -- Locked in a tight battle for the NFC West, the Rams slipped a bit on Sunday with a last-second loss to division rival the San Francisco 49ers.
The 23-20 loss came off a San Francisco field goal in the waning seconds of the game and represented the Rams' first defeat at SoFi Stadium since it opened in Inglewood earlier this year.
The Rams had nearly pulled off a comeback win after slipping into a 17-3 hole by the third quarter. The rally began off a Matt Gay field goal followed shortly by a fumble forced by Aaron Donald and recovered by Troy Hill for six.
They retook the lead 20-17 in the fourth quarter off a rushing touchdown by Cam Akers. But then two field goals by San Francisco's Robbie Gould in the final minutes gave the win back to the Niners.
The Rams also lost (24-16) to the 49ers earlier in the season, on Oct. 18 at Levi's Stadium.
Nick Mullens passed for 253 yards and led two late scoring drives in his first victory as a starter since September for the defending NFC champion Niners (5-6), who stoked their flickering playoff hopes.
After a game largely dominated by defense, Gould hit a 44-yard field goal with 3:11 left before San Francisco stopped Los Angeles near midfield. Fullback Kyle Juszczyk converted a fourth-and-1 with 28 seconds to play during a 56-yard drive in the final 2:10 to set up Gould, who nailed his third field goal of the day after a Rams offside call moved him 5 yards closer.
Rookie defensive lineman Javon Kinlaw returned an interception 27 yards for a touchdown as San Francisco forced four turnovers, including two interceptions and a fumble by Jared Goff.
Aaron Donald forced a fumble and Troy Hill returned it 20 yards for a touchdown late in the third quarter, but the Rams' top-ranked defense couldn't keep the Niners out of field goal range late.
Goff passed for 198 yards in a rough overall offensive game from the Rams, who slipped out of first place in the division with their fourth straight loss to their upstate rivals. Rookie Cam Akers scored the Rams' go-ahead touchdown early in the fourth quarter, but Los Angeles managed just 34 yards on its final two drives.
The defenses largely dominated in the Niners' first visit to the Rams' multibillion-dollar new stadium. The teams combined for four takeaways in the first quarter alone, with the Rams committing two turnovers on their first three drives before Goff fumbled late in the first half.
San Francisco had an early fumble before Mullens threw an interception to Rams rookie Jordan Fuller.
Kinlaw scored his first career TD on his first career interception in his first game back from the reserve/COVID-19 list, rumbling into the end zone after Goff was hit as he threw on the second play of the second half.
The Rams answered with their own defensive touchdown set up by Donald, who had gone without a tackle in two straight games for the first time in his career. The All-Pro lineman was an unstoppable force against San Francisco, and he stripped the ball from Mostert for Hill to return it untouched.
Los Angeles' offense finished its first TD drive with Akers' run early in the fourth quarter after Akers set it up with a 61-yard run.
The Rams, now 7-4, are fighting with the Seahawks for the division. Seattle is 7-3 and faces the Philadelphia Eagles Monday.
Next Sunday the Rams visit another NFC West rival, the Arizona Cardinals, who are 6-5 after losing to the New England Patriots on Sunday.
The Associated Press contributed to this report.
Rams fall to 49ers 23-20 off last-second field goal