Philip Rivers prevailed through a balky back and a sore chest to keep San Diego's slim playoff chances alive.
Those three interceptions in the season's second-to-last week will all but be forgotten if this improbable comeback somehow leads the Chargers into the postseason.
After Rivers led a 21-point rally in the second half, Nick Novak kicked a 40-yard field goal nearly 5 minutes into overtime to give the Chargers a 38-35 victory over the San Francisco 49ers on Saturday night.
Rivers completed his fourth touchdown pass of the day with an 11-yard touchdown pass to Malcom Floyd with 29 seconds left in fourth quarter to tie the score after completing a pair of fourth-and-long passes as the Chargers (9-6) forced overtime.
Phil Dawson's 60-yard field-goal attempt for San Francisco as regulation ended fell way short. Quinton Patton then fumbled in overtime to set up San Diego's winning drive.
On a night nearly everything clicked for the home team until the waning moments, Rivers prevailed despite being down two key playmakers in Keenan Allen and Ryan Mathews.
He shined with the season on the line. The Chargers came in needing to win out and get some help after beginning the week tied with Kansas City and Buffalo, one game out of the final wild-card berth.
Rivers converted fourth-and-8 and fourth-and-10 on the key final San Diego drive of the fourth quarter.
The 49ers blew just their second game when leading by 21 or more at halftime and lost their fourth straight game under embattled coach Jim Harbaugh. They lost 42-41 to Minnesota on Oct. 24, 1965, after leading 35-14 at halftime.
Colin Kaepernick ran 90 yards for a touchdown and Frank Gore had a 52-yard touchdown run as the Niners (7-8) grabbed early momentum.
"Right now there's not much to say," Harbaugh said. "That's a tough one."
Rivers threw touchdown passes of 21 yards and 1 yard to Antonio Gates and another to Eddie Royal, but also was hurt by having three passes intercepted. On one of those, Antoine Bethea had a 49-yard return for his first career touchdown. A defense minus recently released starting lineman Ray McDonald never let Rivers find a rhythm.
The 31-year-old Gore finished with 158 yards and he needs 38 yards in the final game next weekend against Arizona for a fourth consecutive 1,000-yard season and eighth in his 10 NFL seasons. His scoring run was his longest since a 64-yarder on Nov. 1, 2009, at Indianapolis. It also was the longest TD run given up by San Diego since 2010 before Kaepernick topped it.
Gore had more yards in this game than in his previous four games combined, and New York Yankees star Alex Rodriguez was in attendance wearing the running back's red No. 21 jersey.
Rookie Bruce Ellington caught an 8-yard touchdown pass from Kaepernick early in the second quarter that put the Niners up 21-0, then ran for a 1-yard score in the waning moments before leaving with a hamstring injury.
In one half, San Francisco topped its combined scoring total from the previous three games of 23 points. The Niners had their biggest lead since going ahead 28-3 in the third quarter of the season opener at Dallas — and their first lead by 21 points at home since a 34-3 victory over Houston on Oct. 6, 2013.
Rivers, who completed 33 of 54 passes for 356 yards, had his team driving late in the first quarter before throwing an interception picked off by Perrish Cox. Unclear whether ailing, Rivers didn't look comfortable. He sat out Wednesday's practice with neck and back injuries, and he was without running back Ryan Mathews and wide receiver Keenan Allen.
Harbaugh, who is facing a constant swirl of speculation about his future — like a report alma mater Michigan has made him a six-year offer to coach the Wolverines — has said there's still plenty to play for, like a winning season despite the disappointment following three straight trips to the NFC championship game.