SANTA CLARA, Calif. — Rookie Brock Purdy threw two touchdown passes after replacing an injured Jimmy Garoppolo and the San Francisco 49ers used another dominant defensive performance to beat the Miami Dolphins 33-17 Sunday for their fifth straight win.

The 49ers (8-4) allowed a 75-yard touchdown pass to Trent Sherfield on the opening play from scrimmage but little else until the fourth quarter against a high-powered attack for Miami (8-4) which had scored at least 30 points in four straight games.

Jimmie Ward and Deommodore Lenoir intercepted Hawaii native Tua Tagovailoa in the third quarter to lead to two field goals.

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 Nick Bosa that Dre Greenlaw returned for a 23-yard score.

The Dolphins had their five-game winning streak snapped in coach Mike 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 hurt his 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.