FOXBOROUGH, Mass. (AP) — The New England Patriots’ habit of trailing in the fourth quarter was bound to catch up with them.

When it did, it cost them a chance to clinch their fifth straight AFC East title.

Discouraging? Not to defensive end Rob Ninkovich.

“I just look at the next opportunity to play another game,” he said Monday. “You can’t get discouraged in the NFL. If you do, it’s not going to help you the next weekend.”

The Miami Dolphins moved two games behind the Patriots in the division with a 24-20 win over New England on Sunday sealed by Michael Thomas’ interception in the end zone with 2 seconds left after Tom Brady had thrown three straight incompletions.

It was the fifth straight game the Patriots (10-4) were behind in the fourth quarter and the fourth time in that stretch that the outcome was decided in the final minute.

“A game shouldn’t come down to the last four plays,” tight end Michael Hoomanawanui said. “We have to play better throughout the whole game.”

At least they led at halftime on Sunday for the first time in five weeks. But a Miami touchdown drive in the final two minutes cut the Patriots lead to 10-7 at intermission.

“Every NFL football game comes down to a few plays,” Ninkovich said. “In every game, even a game where it’s kind of a blowout, there’s a few (games) that could go the other way if the (plays) are not made.”

Just ask Stephen Gostkowski.

In a 27-26 win over the Cleveland Browns, he kicked a 50-yard field goal in the fourth quarter, then executed the Patriots first successful onside kick in 18 years to set up the winning touchdown pass with 31 seconds left.

But just one week later, in Sunday’s loss to the Dolphins (8-6), Gostkowski failed on a 48-yard field goal attempt in the third quarter, just his third miss of the season. Then he sent a kickoff out of bounds after the Patriots took a 20-17 lead on a 24-yard pass from Brady to Julian Edelman with 4:07 remaining.

That allowed the Dolphins to start from their 40-yard line, and they scored with 1:15 left on a 14-yard pass from Ryan Tannehill to Marcus Thigpen.

“I over-kicked it and was trying to kill the ball,” Gostkowski said. “It was not a good kick at all and my timing was terrible. It was a play that I wish I could take back and it stinks to lose and have such an effect on the game.”

He wasn’t the only culprit.

Brady led the Patriots from their 20-yard line to the Dolphins 19 with 27 seconds left before failing on his final four plays.

Linebacker Dane Fletcher was called for pass interference, leading to a Miami touchdown on the first play of the fourth quarter.

“It’s very disappointing,” special teams captain Matthew Slater said. “We had a chance to wrap the division up. We all knew what was at stake. We didn’t get it done, but the season’s not over with. There’s a lot to play for. All our goals are still attainable.”

Now the Patriots must prepare for another road game against an AFC opponent, at Baltimore on Sunday.

“They’re playing better football now than they were in the beginning of the season,” Ninkovich said.

The Ravens beat the Patriots 28-13 in the AFC championship game in Foxborough last season, outscoring them 21-0 in the second half. But the previous three games between the teams were decided by three points or fewer.

Slater said the Ravens “play the game the right way. They don’t back down from anyone and they always compete. So it’s never easy playing those guys.”

Few games have been easy for the Patriots this season. The final margin has been no more than seven points 11 times.

They’re 7-4 in those games.

“I’m happy that we were able to come out with the wins there at the end and I think that builds mental toughness and character,” Ninkovich said. “We’re going to play as hard as we possibly can until the end.”

AP NFL website: www.pro32.ap.org