Randy Bullock kicked a 44-yard field goal with 4 seconds remaining and the banged-up Tennessee Titans rallied from a 10-point halftime deficit to beat the San Francisco 49ers 20-17 Thursday night.

The Titans (10-5) are a win or a Colts' loss away from clinching their second straight AFC South title despite losing three of their past four games to drop from the AFC's top seed to third. Indianapolis plays Arizona on Saturday.

Ryan Tannehill threw for just 40 yards in the first half but finished with 209 yards and a TD for Tennessee. A.J. Brown caught 11 passes for 145 yards hours after being activated off injured reserve, and his 18-yard TD catch gave Tennessee a 17-10 lead early in the fourth.

TIGHT AFC NORTH PREPARE FOR WILD FINISH TO REGULAR SEASON

Tennessee Titans wide receiver A.J. Brown (11) catches a touchdown pass as he is defended by San Francisco 49ers cornerback Josh Norman, left, in the second half of an NFL football game Thursday, Dec. 23, 2021, in Nashville, Tenn. (AP Photo/Mark Zaleski)

Tennessee Titans wide receiver A.J. Brown (11) catches a touchdown pass as he is defended by San Francisco 49ers cornerback Josh Norman, left, in the second half of an NFL football game Thursday, Dec. 23, 2021, in Nashville, Tenn. (AP Photo/Mark Zaleski)

"It was all on us and we just had to make a play," Brown said. "Then we had to make another play. That was the mindset. Just come out here and make plays, so that’s what we did."

The Titans also picked off two passes, sacked Jimmy Garoppolo twice and forced the Niners to turn it over on downs once.

San Francisco had one final chance. Garoppolo completed a short pass that started a handful of laterals before Jayon Brown finally tackled Pro Bowl receiver Deebo Samuel.

The 49ers (8-7) lost for the second time in seven games as they try to hold onto a wild-card berth in the NFC.

Garoppolo tied it with a 2-yard TD pass to Brandon Aiyuk with 2:20 left, a score set up by a 56-yard catch-and-run by Samuel down to the Tennessee 6.

This was the Niners' first loss after leading by 10 or more at halftime under coach Kyle Shanahan — they had been 18-0 in the regular season and playoffs with those leads. They hadn't blown such a lead since Week 14 of 2016 to the Jets under Chip Kelly.

Tennessee Titans wide receiver A.J. Brown (11) celebrates after scoring a touchdown against the San Francisco 49ers in the second half of an NFL football game Thursday, Dec. 23, 2021, in Nashville, Tenn. (AP Photo/Wade Payne)

Tennessee Titans wide receiver A.J. Brown (11) celebrates after scoring a touchdown against the San Francisco 49ers in the second half of an NFL football game Thursday, Dec. 23, 2021, in Nashville, Tenn. (AP Photo/Wade Payne)

Tennessee played without the left side of its offensive line with left tackle Taylor Lewan out with an injured back and left guard Rodger Saffold on the reserve/COVID-19 list. Rookie Dillon Radunz, a second-round pick out of North Dakota State, replaced Lewan, and the Titans gave up four sacks.

The Niners dominated the first half but missed chances for a bigger lead.

Garoppolo threw for 322 yards and moved the 49ers down the field at ease early, setting up Jeff Wilson's 1-yard plunge on the opening drive and giving them goal-to-go on the second possession. Titans cornerback Jackrabbit Jenkins beat 49ers tight end George Kittle for an interception in the end zone.

A face mask penalty on Pro Bowl left tackle Trent Williams forced the Niners to settle for a 48-yard field goal by Robbie Gould and a 10-0 lead.

SAINTS PREPPING TO START ROOKIE IAN BOOK AFTER TREVOR SIEMIAN, TAYSOM HILL PLACED ON COVID LIST: REPORT

The Niners led 10-0 at halftime, their first time shutting out an opponent in the first half since the 2019 NFC title game against Green Bay. That also marked four straight scoreless quarters for the Titans.

Tennessee finally strung together a 13-play drive to open the third quarter, matching its first-half production at 55 yards, with Tannehill completing three straight passes on third down until missing a screen to Jeremy McNichols. Bullock kicked a 38-yard field goal to pull the Titans within 10-3.

Tennessee Titans kicker Randy Bullock (14) watches his 44-yard field goal in the final seconds of the fourth quarter of an NFL football game against the San Francisco 49ers Thursday, Dec. 23, 2021, in Nashville, Tenn. The field goal gave the Titans a 20-17 win. (AP Photo/Wade Payne)

Tennessee Titans kicker Randy Bullock (14) watches his 44-yard field goal in the final seconds of the fourth quarter of an NFL football game against the San Francisco 49ers Thursday, Dec. 23, 2021, in Nashville, Tenn. The field goal gave the Titans a 20-17 win. (AP Photo/Wade Payne)

Titans safety Amani Hooker picked off his first pass this season on the Niners' next play, returning it 21 yards to the San Francisco 18. D'Onta Foreman finished that short drive with a tying 3-yard TD run.

CLICK HERE TO GET THE FOX NEWS APP

Then the Tennessee defense, as healthy as it's been in weeks, forced the Niners to turn it over on downs at the Titans 41 late in the third after having fourth-and-1 when Williams false started.

INJURIES

Samuel returned after going down at the end of his 56-yarder, and Niners defensive lineman D.J. Jones hurt an ankle. Titans defensive lineman Naquan Jones went down late in the third quarter. Brown had been out since injuring his chest in Week 11 against Houston.

UP NEXT

Niners host Houston on Jan. 2 in their regular season home finale.

Titans host Miami on Jan. 2 in their regular season home finale.