SANTA CLARA (AP) Jimmy Garoppolo threw a 25-yard touchdown pass to Jeff Wilson Jr. with 31 seconds left for his fourth TD pass of the game and the San Francisco 49ers rallied for a 36-26 victory over the Arizona Cardinals on Sunday.
Garoppolo connected with Wilson over the middle for the go-ahead score one play after the Niners (9-1) narrowly converted on a third-and-3 pass that went to replay review.
Instead of being ruled short and having to decide whether to kick a tying field goal or go for it on fourth down, San Francisco had a new set of downs and took advantage on Wilson's first career touchdown catch.
David Johnson fumbled on the next play for the Cardinals (3-7-1), who squandered a 16-0 lead and lost their fourth straight game. San Francisco added a fumble recovery for a touchdown by D.J. Reed on the final play after a botched lateral by Arizona.
This marked the biggest deficit erased by the 49ers in a win since rallying from 20 points down to beat Philadelphia on Oct. 2, 2011. San Francisco also overcame a 17-point deficit in the NFC title game at Atlanta following the 2012 season.
Garoppolo threw for 425 yards and four touchdowns, but also threw two interceptions deep in Arizona territory that nearly doomed the 49ers. The first set up a field goal that put Arizona up 19-17 and the second came with San Francisco trailing by three late in the fourth quarter.
The defense responded by forcing a three-and-out on a sack by Arik Armstead. Garoppolo then went 6 of 7 for 58 yards on the game-winning drive.
Kyler Murray threw two TD passes and put the Cardinals ahead 26-23 on a 22-yard keeper with 6:30 to play but it wasn't enough to beat the 49ers.
The Cardinals scored on their first two drives to take a 9-0 lead when Murray found Larry Fitzgerald all alone for a 5-yard score that was his 19th career touchdown against San Francisco.
Arizona added to the lead in the second quarter on a 5-yard TD pass from Murray to Pharoh Cooper before the Niners mostly abandoned an ineffective running game to get back into the contest thanks to a series of underneath passes.
Richie James Jr. took a screen 57 yards to set up Garoppolo's first of two TD passes to backup tight end Ross Dwelley. San Francisco settled for a field goal at the end of the half before Garoppolo and Dwelley connected again on the opening drive of the third quarter to put the Niners up 17-16.
San Francisco looked poised to add to that lead with a drive down to the 12 before Garoppolo threw an interception right to linebacker Jordan Hicks, whose 48-yard return set up a go-ahead field goal by Zane Gonzalez.