SANTA CLARA, Calif. -- - The Miami Dolphins hit San Francisco's vaunted defense with a 75-yard haymaker on the opening play and then watched 49ers quarterback Jimmy Garoppolo leave with a season-ending foot injury.
Everything was set up for another win for the streaking Dolphins, but backup quarterback Brock Purdy and the Niners had other ideas.
Purdy threw two touchdown passes after replacing Garoppolo and San Francisco used another dominant defensive performance to beat Miami 33-17 on Sunday for its fifth straight win.
"Guys were a little off, just in general collectively," Dolphins coach Mike McDaniel said. "But I know one thing: It wasn't because of preparation, lack of detail. It was one of those things that you have to go through."
Tua Tagovailoa threw a 75-yard touchdown pass to Trent Sherfield on the opening play from scrimmage but struggled to do much else behind a patchwork line for Miami (8-4) against Nick Bosa and the Niners' defense.
"It sucks that we didn't come out and say what we wanted to do collectively as a team," Tagovailoa said. "Obviously, it starts with me offensively. Turnovers, with third-down communication errors, in that retrospect it's hard to win a game when you're not on your Ps and Qs and you're not dialed in."
The 49ers had their four-game, second-half shutout streak snapped when Tagovailoa threw a 45-yard TD pass to Tyreek Hill in the opening minute of the fourth quarter but held on from there. They capped the performance with a strip-sack from Bosa that Dre Greenlaw returned for a 23-yard score.
"We didn't flinch," Niners linebacker Fred Warner said about the response to the opening play. "We came back to the sideline and you can't look at things like that emotionally. You've got to just look at it for what it is and and see how you can adjust. I guess that kind of allowed us to really settle into the game quicker, obviously when you when you have a play like that."
The Dolphins had their five-game winning streak snapped in coach McDaniel's first game against the 49ers after spending the past five years as an assistant in San Francisco.
Purdy, dubbed "Mr. Irrelevant" as the last pick of this year's NFL draft, proved to be quite important to the 49ers when Garoppolo broke his left foot on a sack on the final play of the opening drive.
Garoppolo was taken to the locker room on a cart and didn't return, leaving the game in the hands of Purdy, who had thrown his only nine passes in mop-up duty of a Week 7 loss to Kansas City.
Purdy capped his first drive of the game by throwing a 3-yard TD pass to Kyle Juszczyk to give San Francisco a 10-7 lead.
He then led a well-executed two-minute drive at the end of the half, completing six passes for 75 yards with a 3-yard TD to Christian McCaffrey with 4 seconds left in the half to make it 17-10.
Purdy finished 25 for 37 for 210 yards, two TDs and one interception.
"It's pretty crushing. We know what Jimmy's been through, how hard he's worked at this," coach Kyle Shanahan said. "That was a really cool game, just as a team and all the stuff that went on throughout the game and just be able to overcome some things. So it's such a special win. But definitely mixed emotions hearing about Jimmy."
Shanahan won two challenges in the fourth quarter to overturn completed passes by Miami. The second came on a fourth-and-2 play with the Niners leading by six with about six minutes left.
The Niners held the ball for nearly four minutes and made it a two-score game when Robbie Gould kicked a 48-yard field goal, his fourth of the day.
The Dolphins wasted little time showing off their speed when Tagovailoa connected on the long touchdown to Sherfield on the first play from scrimmage.
It marked the first time a team scored on the first play after the opening kick since the Niners did it in Week 2 of the 2020 season against the Jets with an 80-yard run by Raheem Mostert.
The touchdown ended a scoreless streak of more than 94 minutes for the 49ers, who hadn't allowed a point since the second quarter against Arizona two weeks ago.
Miami hadn't scored a TD on the first play from scrimmage following the opening kick since the final game of the 2004 season when Sage Rosenfels threw a 76-yard pass to Chris Chambers against Baltimore.
Dolphins: WR Jaylen Waddle left in the first half with a leg injury but returned to the game.
49ers: San Francisco already lost starting QB Trey Lance to a season-ending ankle injury in Week 2. The only other QB under contract is Jacob Eason, who is on the practice squad. ... DT Hassan Ridgeway (pectoral) left in the fourth quarter and didn't return.
Dolphins: Visit the Los Angeles Chargers on Sunday night.
49ers: Host Tampa Bay on Sunday.
AP NFL: https://apnews.com/hub/nfl and https://twitter.com/AP--NFL