SANTA CLARA, Calif. (AP) — Four nights after winning the highest-scoring game of the NFL season, the Los Angeles Rams won the only game this year that didn't have a touchdown.

Joshua Karty kicked four field goals and the Rams survived a slugfest a week after winning a shootout, beating the San Francisco 49ers 12-6 on Thursday night in a key game in the NFC West race.

“What’s really cool is this team has found a bunch of different ways to be able to win football games," coach Sean McVay said. “You come off a 44-42 game the other day and then you win 12-6. Our group did what they needed to do to be able to get it done.”

The Rams (8-6) followed up the high-scoring win over Buffalo by winning for the seventh time in nine games following a 1-4 start. The Rams moved within a half-game of division-leading Seattle. Los Angeles won a game without a touchdown for the first time since 2016.

The 49ers (5-8) led 6-3 heading into the fourth quarter but came up short, dealing a major blow to the dwindling playoff hopes for the defending NFC champions.

This marked the fourth time this season that the Niners lost to a division opponent after leading by at least three points in the fourth quarter, making them the first team to do that since New England in 2000 in coach Bill Belichick's first season with the Patriots.

“It was the story of the year,” linebacker Fred Warner said. “Just not doing enough to win games. Not playing complementary. Just coming out a little too short.”

Karty capped a 17-play drive with a game-tying 23-yard field goal early in the fourth quarter and then hit a 27-yarder after Matthew Stafford connected on a 51-yard pass to Puka Nacua.

Karty made all four kicks after missing four in the past five games of his rookie season.

“He’s steady,” McVay said. “He’s consistent. He’s kind of unflappable.”

The Niners then drove into field-goal range but Brock Purdy was intercepted on a deep pass into the end zone by Darious Williams, helping the Rams secure their first series sweep against the 49ers since 2018.

Stafford then led a clock-killing drive that was capped by Karty's fourth field goal with 18 seconds to play. Stafford went 16 for 27 for 160 yards, with 137 of those yards coming after halftime when the heavy rain stopped.

“In the second half, the weather was good enough to do it all,” Stafford said. “We had the feeling that that was the kind of way this game was going to be played and it’s going to have to be one of those games. We scored 44 four nights ago and come out here and score 12 but they both count for one.”

Purdy finished 14 for 31 for 142 yards as the Niners failed to score a touchdown in a game for the first time since 2019.

The first half was played in a downpour and it had a major impact on the offensive performances with neither team able to move the ball.

The Rams had no first downs on their first four drives for the first time since 2013 before getting a late field goal to tie the game. The Niners went three-and-out three times and got one field goal.

The teams combined for 11 punts, nine first downs and 197 yards four days after they both had season highs in points.

The rain mostly stopped at halftime but the offenses still struggled.

Injuries

Rams: LB Nick Hampton (chest) left in the second half.

49ers: LB Dre Greenlaw returned for the first time since tearing his left Achilles tendon in the Super Bowl last season. He had eight tackles in the first half but played sparingly in the second half. Veteran De'Vondre Campbell, who lost his starting role when Greenlaw returned, refused to enter the game in the second half, according to coach Kyle Shanahan. ... S Ji'Ayir Brown (groin) left in the second half.

Up next

Rams: Visit the New York Jets on Dec. 22.

49ers: Visit Miami on Dec. 22.

___

AP NFL: https://apnews.com/hub/NFL

Los Angeles Rams place kicker Joshua Karty (16) kicks a field goal from the hold of Ethan Evans during the second half of an NFL football game against the San Francisco 49ers in Santa Clara, Calif., Thursday, Dec. 12, 2024. (AP Photo/Jed Jacobsohn)

Credit: AP

icon to expand image

Credit: AP

Los Angeles Rams cornerback Darious Williams (24) intercepts a pass in front of San Francisco 49ers wide receiver Jauan Jennings (15) during the second half of an NFL football game in Santa Clara, Calif., Thursday, Dec. 12, 2024. (AP Photo/Godofredo A. Vásquez)

Credit: AP

icon to expand image

Credit: AP

Los Angeles Rams wide receiver Puka Nacua (17) reacts after catching a pass against the San Francisco 49ers during the second half of an NFL football game in Santa Clara, Calif., Thursday, Dec. 12, 2024. (AP Photo/Godofredo A. Vásquez)

Credit: AP

icon to expand image

Credit: AP

San Francisco 49ers linebacker Dre Greenlaw (57) watches as Los Angeles Rams quarterback Matthew Stafford (9) stands behind center during the second half of an NFL football game in Santa Clara, Calif., Thursday, Dec. 12, 2024. (AP Photo/Godofredo A. Vásquez)

Credit: AP

icon to expand image

Credit: AP

San Francisco 49ers quarterback Brock Purdy (13) passes as Los Angeles Rams linebacker Jared Verse (8) applies pressure during the second half of an NFL football game in Santa Clara, Calif., Thursday, Dec. 12, 2024. (AP Photo/Godofredo A. Vásquez)

Credit: AP

icon to expand image

Credit: AP

Rain falls as Los Angeles Rams quarterback Matthew Stafford signals at the line of scrimmage during the first half of an NFL football game against the San Francisco 49ers in Santa Clara, Calif., Thursday, Dec. 12, 2024. (AP Photo/Godofredo A. Vásquez)

Credit: AP

icon to expand image

Credit: AP

San Francisco 49ers wide receiver Deebo Samuel Sr. (1) runs against the Los Angeles Rams during the second half of an NFL football game in Santa Clara, Calif., Thursday, Dec. 12, 2024. (AP Photo/Godofredo A. Vásquez)

Credit: AP

icon to expand image

Credit: AP

Los Angeles Rams quarterback Matthew Stafford, left, runs against San Francisco 49ers linebacker Fred Warner during the second half of an NFL football game in Santa Clara, Calif., Thursday, Dec. 12, 2024. (AP Photo/Jed Jacobsohn)

Credit: AP

icon to expand image

Credit: AP

Los Angeles Rams quarterback Matthew Stafford (9) passes against the San Francisco 49ers during the first half of an NFL football game in Santa Clara, Calif., Thursday, Dec. 12, 2024. (AP Photo/Jed Jacobsohn)

Credit: AP

icon to expand image

Credit: AP

Rain falls as San Francisco 49ers quarterback Brock Purdy (13) tries to scramble before being sacked by Los Angeles Rams defensive tackle Kobie Turner, left, during the first half of an NFL football game in Santa Clara, Calif., Thursday, Dec. 12, 2024. (AP Photo/Godofredo A. Vásquez)

Credit: AP

icon to expand image

Credit: AP

Los Angeles Rams defensive tackle Kobie Turner (91) celebrates with linebacker Byron Young (0) after sacking San Francisco 49ers quarterback Brock Purdy during the first half of an NFL football game in Santa Clara, Calif., Thursday, Dec. 12, 2024. (AP Photo/Godofredo A. Vásquez)

Credit: AP

icon to expand image

Credit: AP