FOXBOROUGH, Mass. — The New England Patriots emphasize playing well for 60 minutes every game. On Saturday, 30 was enough — barely.

Rallying from their worst half of the season, the Patriots scored on their next five possessions and clinched a playoff bye with a 27-24 win over the Miami Dolphins on Saturday.

“You don’t want to, certainly, make a habit of this,” said Tom Brady, who scored on two 1-yard sneaks and threw for a 1-yard touchdown. “We showed some resiliency.”

New England (12-3) won its seventh straight game. After the Houston Texans lost to the Indianapolis Colts on Thursday night, the Patriots needed a win or a tie to lock up one of the top two spots in the AFC.

“It’s good to clinch,” said Deion Branch, who caught the touchdown pass from Brady, “but not by the way we played. It’s not the way you want to do it.”

Miami (5-10) lost for the third time in eight games after opening at 0-7 and is 1-1 under Todd Bowles, who took over when Tony Sparano was fired.

“First half we came out and played our tempo and our ballgame,” Bowles said. “The second half they made us play theirs.”

The AFC East champions trailed 17-0 at halftime but made the necessary adjustments and went to their no-huddle offense more, keeping the Dolphins from making defensive substitutions. And Brady was on target after a first half in which heavy defensive pressure against a makeshift offensive line affected his accuracy. He completed just 7 of 19 passes for 87 yards and was sacked three times in the half.

But in the second half, he completed 20 of 27 passes for 217 yards, finishing at 27 for 46 for 304 yards and leading one scoring drive after another — a 45-yard field goal by Stephen Gostkowski, the scoring pass to Branch, his own sneak that tied the game, Gostkowski’s 42-yard go-ahead kick after Devin McCourty’s first interception of the year, and the other sneak with 2:56 to go, making it 27-17.

The Dolphins made it closer on Matt Moore’s 15-yard scoring pass to Davone Bess with 1:48 to play. They had three timeouts left, but their hopes faded when Brady hit Wes Welker for a 6-yard gain and a first down.

“We had (Brady’s) number in the first half, but in the second half he came out and made a lot of plays,” Miami linebacker Karlos Dansby said. “He is a coach on the field.”