FOXBOROUGH, Mass. (AP) -- Tom Brady erased a 24-point deficit. Peyton Manning's touchdown pass forced overtime.
The game was in the hands of two great quarterbacks.
Then a punting duel ensued and a live ball hit the leg of a backup cornerback.
Tony Carter ran into Ryan Allen's punt after it bounced, Nate Ebner recovered for the Patriots at the Broncos 13-yard line and Stephen Gostkowski kicked a 31-yard field goal with 1:56 left in overtime to give New England a 34-31 win over Denver on Sunday night.
"What a crazy game and what a fun finish," Gostkowski said.
The Patriots lost fumbles on their first three possessions and they were booed several times in the first half.
But Brady threw for three touchdowns to lead the Patriots (8-3) from a 24-0 halftime deficit against the NFL's best offense for a 31-24 lead as New England scored on its first five possessions of the second half. Then Manning threw an 11-yard scoring pass to Demaryius Thomas for the Broncos (9-2), tying it at 31.
"You can't move the ball when you're losing it," Patriots coach Bill Belichick said. "You've got to hang onto it."
But Carter's gaffe was the third lost fumble for the Broncos in the second half.
"It was really a tale of two halves," Denver interim coach Jack Del Rio said. "We forced turnovers and jumped on them early. They forced turnovers and jumped on us at the end.
"We just had a fluke play at the end."
The game marked the return of former Patriots receiver Wes Welker, who signed with Denver in the offseason. He was a non-factor with four catches for 31 yards. The crowd even chanted "Wel-ker, Wel-ker," when he went back to return the final punt. Then he waved his hands to warn his teammates to stay away from the ball when it bounced.
Carter didn't and the Broncos remained tied with the Kansas City Chiefs for the AFC West lead. The Patriots lead the AFC East by three games.
"I was running to get away from the ball and it took a bounce right into me," Carter said.
The early turnovers helped Denver to a big halftime advantage, but the Patriots took the lead when Brady hit Julian Edelman for a TD early in the fourth. Gostkowski's 31-yard field goal made it 31-24 midway through the fourth.
"We had some plays in the first half that didn't go our way so it was nice to get a good bounce and we needed it," Brady said.
But Manning, who had thrown for only 73 yards in the first 3 1/2 quarters, led the Broncos on an 80-yard drive. Twice the Broncos were rescued by penalties: First when a defensive holding penalty negated an interception, and again when a pass interference on third-and-7 from the Patriots 17 gave Denver a first down.
On the next play, Manning lobbed one to Thomas in the left corner of the end zone to tie it.
Manning had his worst game of the season, completing 19 of 36 passes for 150 yards, two touchdowns and one interception. He is 4-10 in his career against Brady.
"Hated the way that ended, not getting a chance to get our hands on the ball," Manning said. "We helped them with some short fields. It's hard to do that to our defense."
Brady had one of his best games, connecting on 34 of 50 passes for 344 yards, three touchdowns and no interceptions.
Brady led the Patriots to three straight touchdowns in the third quarter to cut Denver's lead to 24-21 heading into the fourth.
He led New England 80 yards for a touchdown to open the second half, thanks to a 33-yard completion to Rob Gronkowski and a 5-yard scoring pass to Edelman. Montee Ball coughed it up on Denver's next possession, and six plays later Brandon Bolden ran it in from the 1 to make it a 10-point game.
A 6-yard touchdown pass to Gronkowski with 19 seconds left in the third quarter cut the Broncos' lead to 24-21.
"We calmed down. We played each play one play at time," Edelman said of the difference in the second half. "We didn't turn the ball over in the second half."
Von Miller returned a fumble 60 yards for a touchdown and then strip-sacked Brady to force another turnover in the first quarter, setting up Knowshon Moreno's 2-yard TD run. Moreno finished with a career-high 224 yards on 37 carries.
When New England got the ball back, it held onto it for just two plays before LeGarrette Blount had it knocked loose by safety Duke Ihenacho. Linebacker Danny Trevathan fell on it.
Denver settled for Matt Prater's 27-yard field goal that made it 17-0. The Broncos added another touchdown when Manning hit Jacob Tamme from 10 yards out for the only score of the second quarter.
New England had lost five fumbles all season coming into the game and was sixth in the NFL in net turnovers. But Stevan Ridley, who coughed it up on the opening drive, has fumbled in three consecutive games, losing two.
The temperature made it difficult for the players on each side and also could have been the reason that first the play clocks and then the game clocks went out, forcing the referees to keep the official time on the field. The clocks came back early in the second quarter.
NOTES: The Patriots were underdogs at home for the first time since 2005 but improved to 6-0 at Gillette Stadium this season. ... The Broncos added to their NFL record by scoring 25 points or more for the 16th straight game. ... Edelman finished with nine catches for 110 yards.