FOXBOROUGH, Massachusetts — The New England Patriots lost quarterback Jimmy Garoppolo, then almost the lost game.

Garoppolo, starting his second straight game during Tom Brady’s Deflategate suspension, had already thrown three touchdown passes when he suffered a right shoulder injury with 4:02 left in the second quarter — and New England almost blew a 31-3 lead but held on for a 31-24 victory over the Miami Dolphins on Sunday.

Ryan Tannehill threw for 389 yards after a zero first quarter and the Dolphins (0-2) cut their deficit to seven with 6:06 left. The power running of LeGarrette Blount led to a 39-yard field attempt by the usually reliable Stephen Gostkowski with 1:04 left.

The Dolphins marched 42 yards to the New England 29 but Duron Harmon picked off Tannehill’s fourth-down pass in the end zone with two seconds left.

Garoppolo was taken to the turf after a scramble by linebacker Kiko Alonso. The pass was completed for a first down but Garoppolo, who appeared to have also been limping slightly just before the play, got up slowly. He went to a knee as the training staff worked on him and grimaced when his shoulder was touched inside his shoulder pad.

The Patriots (2-0) have just three days to prepare for Thursday night’s game against the Houston Texans.

Garoppolo was 18 of 27 for 234 yards before leaving — 42 of 60 for 498 yards, four touchdowns and no interceptions in two games.

Rookie Jacoby Brissett made his NFL debut and was 0 of 2 — both passes seemed catchable — before a Stephen Gostkowski field goal ended the first half.

Brissett then led the team on a touchdown drive on the first drive of the second half, with Blount scoring on 9-yard touchdown run.

Brissett finished 6 of 9 for 92 yards.

Tight end Martellus Bennett caught five passes for 114 yards, including a 20-yard touchdown and a powerful catch and run that featured a stiff arm against cornerback Bryan Maxwell, and a touchdown. Blount ran for 123 yards and a touchdown and Danny Amendola caught two touchdown passes and had four catches.

The win was the eighth straight for the Patriots at home against Miami.

Tannehill, who had a dreadful beginning (0 of 2 in the first quarter), rallied and finished 30 of 39 for 364 yards, two touchdowns and an interception. He is 0-5 at Gillette Stadium and was working for the entire second half without injured running back Arian Foster.

It was not known who would have entered if Brissett was injured, but wide receiver Julian Edelman, who caught seven passes for 76 yards, was a college quarterback. The team will likely quickly sign a backup for Brissett if Garoppolo’s injury is serious.

NOTES: TE Rob Gronkowski (hamstring) missed his second straight game while New England LB Dont’a Hightower (knee) was also inactive. … The Dolphins had DE Mario Williams and WR DeVante Parker, both questionable, active. … The Patriots honored a Red Sox great before the game — David Ortiz coming out of the tunnel wearing a Tom Brady No. 12 jersey but quickly added a No. 34 presented to him by Patriots owner Robert Kraft — with “Big Papi” on the back. … Dolphins RB Arian Foster, WR Kenny Stills and S Michael Thomas kneeled on the Miami sideline during the national anthem. All New England players stood and TE Martellus Bennett and S Devin McCourty, who raised fists into the air after the anthem Sunday night in Arizona, did not do it again. … The Patriots honored new team Hall of Famer Kevin Faulk at halftime, with Faulk opening the door for the team before it came out onto the field.