FOXBOROUGH — If there was ever a time the Patriots were going to begin to turn around their third-quarter issues, Sunday was it.

The Dolphins had them on the ropes and in a two-touchdown hole after the first 30 minutes. New England’s offense had totaled a measly 59 yards, quarterback Tom Brady already had thrown an interception, standout right tackle Sebastian Vollmer had been carted off with a broken bone in his lower right leg, and the defense had allowed Miami to gain 175 yards, go 6 for 10 on third-down conversions, and score touchdowns on both red-zone trips.

There was talk all week around Gillette Stadium about the Patriots’ third-quarter woes. Entering the game, they’d yet to score a touchdown in the quarter, outscored almost five-to-one by opponents.

Whatever was said or shown or thought or felt at halftime — no one was revealing much after the game — worked for New England on Sunday, and the team rode its best third quarter of the season by far — it outscored Miami, 17-0 — to a 27-17 come-from-behind win over its division rival.

“We come in at halftime and we were not playing good football at all; the first half was not a good half of football,” defensive end Rob Ninkovich said. “I don’t think we played well at all. We had to start over again. The third quarter was like the first quarter — we had to play that second half like we started in another football game and just try to completely change how we were playing because it wasn’t working.”

The turnaround wasn’t immediate: The Patriots won the toss and deferred, meaning they got the ball to open the third. They promptly went three-and-out.

And Miami continued to move the ball effectively, getting into the red zone for the third time. But Dont’a Hightower sacked Ryan Tannehill on third and short, and rookie kicker Caleb Sturgis hit the right upright on his 46-yard field goal attempt.

That’s when the tide began to turn for New England.

Starting at their 36 after the missed field goal, the Patriots made short work of things, totaling more yards on their 64-yard touchdown drive than they had in the opening 30 minutes of the game.

Stevan Ridley’s 23-yard carry, helped by some good blocking from Kenbrell Thompkins, started things, and a 23-yard catch by Rob Gronkowski got them inside the 20. Two plays later, Brady looked to Aaron Dobson, connecting with the rookie in the left third of the end zone even as the QB was hit by linebacker Philip Wheeler.

The Patriots finally had that elusive first third-quarter touchdown of the season, and it was their first TD in 16 possessions, dating to the second quarter of their Week 7 loss to the Jets.

That was followed closely by the second third-quarter touchdown of the year.

Rookie cornerback Logan Ryan, who did not play on defense in the first half — he denied after the game it was for disciplinary reasons, though he was fined by the NFL for grabbing his crotch during his pick-six touchdown a week earlier — blitzed Tannehill on second down, and stripped the ball from the quarterback.

Ninkovich, as he’s done on numerous other occasions with the Patriots, was there to recover the ball, and the offense was just 13 yards from the end zone.

The Patriots scored again before the third quarter ended, on a Stephen Gostkowski field goal, though a Gronkowski touchdown was taken off the board when Nate Solder was flagged for holding.

Still, the 17 points they scored in the third was nearly double the 9 points they’d managed in the third quarter of their first seven games — total.

“We dug a big hole for ourselves there at halftime and really haven’t played good in the third quarter all year, but we did today,” coach Bill Belichick said.

Said offensive lineman Logan Mankins, “We always look at things that we’re not doing well and try to improve on those, and there was a lot said this week about the third quarter, how we needed to play better, from players, coaches, everyone in this building, so it was really nice to have a good quarter.”

And a week after an obscure NFL rule went against the Patriots in their loss to the Jets, a less-obscure but still not-often-called one worked in their favor in the fourth quarter and played a big role in their game-sealing touchdown.

Facing second and 7 from the Dolphins’ 23, Brady was strip-sacked by safety Jimmy Wilson.

Miami’s Olivier Vernon went after the loose ball, and it squirted away from him. Solder finally recovered it for the Patriots, but not until the ball was near midfield.

But the officials flagged Vernon for an illegal bat, saying he deliberately knocked the ball away from a New England player. The penalty was enforced at the point of the foul, the 23-yard line, giving the Patriots 10 yards and a fresh set of downs.

“The referee made the call,” Vernon said, never denying that he was trying to push the ball away. “I was trying to make a play, but the referee made that call. Just need to move forward now.”

Dolphins coach Joe Philbin said, “Our stance was we thought he was trying to recover it and they said he illegally batted it.”

New England ran four running plays from the 13, with Ridley getting into the end zone from 3 yards out.

There was a great deal of talk about Brady’s right hand after the game, and the appendage received a great deal of air time on CBS, but he insisted that it is “perfect,” though he kept the hand in his sweater pocket the entire time he was at the podium after the game, not allowing cameras to get a shot of it.

New England hits the midway point of the season at 6-2 and in control of the AFC East, with a struggling Pittsburgh club headed to Gillette next Sunday before the Patriots enjoy their bye in Week 10.

The Patriots were able to fix the third quarter for one day, but as Mankins noted, there remains work to do.

“Still haven’t played 60 minutes,” he lamented. “We played 30 minutes today, so once we get going with 60 minutes of good football, I think we’ll be more where we want to be.”