SANTA CLARA >> If the 49ers were bound to vanish from playoff contention by mid-December, it only made sense for them to blow another NFC West game in the fourth quarter.

This time the 49ers had only a 6-3 lead to protect, and, in the end, they walked off their soggy field Thursday night with a 12-6 defeat to the Los Angeles Rams.

Officially, the reigning NFC champs are not eliminated. But, with a 6-8 record overall and a 1-4 mark in division games, the 49ers’ playoff chances are at less than 1 percent, according to the New York Times’ simulator.

Thursday night’s turning point wasn’t Joshua Karty’s third field goal of the night that gave the Rams (8-6) their first lead with 9:29 remaining; he made a 29-yarder with 18 seconds remaining.

Rather, take your pick of the 49ers’ turn for the worse: Brock Purdy’s fourth-quarter pass that got intercepted at the goal line, or Dre Greenlaw’s third-quarter exit to end his sensational season debut 10 months after an Achilles tear in the Super Bowl.

Disgruntled 49ers’ fans also might point to Deebo Samuel, who drew boos upon a third-round drop that could have resulted in the game’s only touchdown. That came midway through the third quarter, forcing the 49ers to settle for Jake Moody’s 47-yard field goal and a 6-3 lead. Samuel, upon that drop, grabbed his head in disgust, fans booed, and he kept running his crossing route all the way to the sideline, where he stripped off his helmet and took a seat on the bench.

Samuel’s best move of the night came on the Rams’ final kickoff, which he returned 41 yards and drew a penalty on the Rams’ horse-collar tackle.

With 11 seconds remaining, the 49ers were at midfield, needing a miraculous touchdown. Instead, Brock Purdy uncorked a final incompletion (14-of-31, 142 yards) and then got sacked as time expired.

Once Karty’s 27-yarder put the 49ers behind 9-6, they responded with gritty work to reach Moody’s range for a potential third field goal from him, too. Then came the 49ers’ biggest slipup on what began as a very rainy night. On second-and-10 from the Rams’ 33-yard line, Purdy got intercepted at the goal line on a second-and-10 floater to a double-covered Jauan Jennings down the right sideline, with Darius Williams making the interception for the game’s first turnover with 5:14 remaining.

That spoiled a drive highlighted by completions to Ricky Pearsall (16 yards) and George Kittle (9 yards), as well as a 10-yard run by Guerendo to that 33-yard line. On the previous snap, Purdy underthrew an open Pearsall on a 40-yard shot.

The 49ers’ defense certainly lost some luster when Greenlaw exited to the bench with what appeared to be issues with his right calf and left knee.

Muddled in a 6-6 tie, the Rams broke through for the game’s longest play: a 51-yard connection from Matthew Stafford to Puka Nuakua (past Charvarius Ward) at the 49ers’ 16-yard line. Back-to-back run stops by safety Tashaun Gipson set the stage for Fred Warner’s best play in months, that being his stop of a Kyren Williams catch for no gain on 3rd-and-2 catch at the 8-yard line.

The Rams pulled even with 13:38 remaining in regulation, when Stanford product Karty connected on a 23-yard field goal to salvage a drive that reached the 49ers’ 4-yard line before stalling out on Stafford incompletions and holding penalties.

Amid that 17-play, 63-yard tying drive by the Rams, Greenlaw bowed out and headed for the sideline. He did so after putting a hit on Blake Corum, but Greenlaw subsequently limped off to the 49ers’ bench and met with team training staff. He had eight tackles (six in the first half) and keyed the defensive charge up to that point.

The 49ers took a 6-3 lead into the fourth quarter, but was far from the bigger advantages they blew in notorious losses to the Rams: they led 24-14 in a Week 3 defeat (27-24) at SoFi Stadium, and they owned a 17-7 lead in the 2021 season’s NFC Championship Game (20-17).

The 49ers scored on their first possession of each half, doing so on Moody field goals of 53 and 47 yards.

Samuel produced just 19 yards on the night: 16 yards by catching 3-of-7 targets, and the other three yards coming on two carries. He had just 15 yards on five touches before halftime, after griping on social media Monday about his self-perceived lack of opportunities. He also had a false-start penalty, and he unofficially made a tackle when he collided with Isaac Guerendo in the backfield.

The 49ers grabbed a 3-0 lead via Moody’s 53-yard field goal on their second series, which opened with a 33-yard reception by Kittle. The drive stalled when Deebo Samuel was stopped for a 2-yard gain on third-and-6, after earlier colliding on a backfield-motion play with Isaac Guerendo to halt his 1-yard run.

The Rams tied it at 3 with 1:05 until the halftime show (corgi races). Karty made a 48-yard field goal to bail out the Rams’ first-half offense in which Stafford completed just 4-of-12 passes for 23 yards, with running back Williams totaling 44 yards on 14 carries.

Guerendo, making an encore start and playing through Sunday’s foot sprain, had just 17 yards on eight carries in the first half. He finished with 57 yards on 16 carries, plus 18 yards on four catches.

The 49ers’ starting defense welcomed back not only Greenlaw but also defensive end Nick Bosa, who missed the previous three games with an oblique injury. Safety Talanoa Hufanga, two games into his return from a two-month break, made an early impact against the run. By the fourth quarter, Ji’Ayir Brown (groin) was out and Tashaun Gipson returned to pair with Hufanga like the previous two seasons.

The Rams, denied a first down on their opening four possessions, approached midfield midway on a second-quarter series, only to stall at their own 41-yard line as Stafford fell to 0-for-5 on third-down throws; he earlier kept that fifth series alive with a third-and-10, 11-yard run that ended on big hits from Deommodore Lenoir and Warner.

But the 49ers were up only 3-0, unable to get their own offense moving. With five minutes until halftime, the Rams’ Stafford completed just 2-of-10 and Williams ran for just 28 yards on 9 carries. Stafford finished 16-of-27 for 160 yards.

The Rams’ inability to get a first down in their first four drives marked ther longest such streak to start a game in Sean McVay’s eight seasons. Third-down defense proved pivotal: Lenoir and Hufanga each dropped potential interceptions, Stafford’s next third-down throws sailed incomplete, with Bosa hitting him to cap that fourth series.