FOXBORO — The Patriots talked about it all week: To beat a team like the Bills and a quarterback like reigning NFL MVP Josh Allen, they needed to execute for a full 60 minutes.

Their defense couldn’t muster half of that on Sunday.

After forcing three straight punts to open the game, New England surrendered five consecutive Allen-led touchdown drives. Buffalo erased a 21-0 deficit to win 35-31 at Gillette Stadium and delay the Patriots’ coronation as the new champions of the AFC East.

The 35 points were the most the Patriots have allowed in a game this season.

“I mean, we weren’t able to get any stops,” Patriots head coach Mike Vrabel said. “When we had an opportunity to make a play, we weren’t able to make it. Penalties. And that’s how this game goes. A few small plays make the difference. We were very prepared for this team to — we were going to need 60 minutes to beat this team. This is a good football team. We had a lot of good football in there. And we had a lot of plays that — a few plays we’d like to have back that we’ll have to learn from.”

The Bills’ first two touchdown drives came off short fields created by special teams miscues — first a Brenden Schooler facemask that set Buffalo up at New England’s 42-yard line, then a 58-yard Ray Davis kickoff return to open the second half. The final three featured drive-extending penalties by defensive backs Craig Woodson (defensive holding), Marcus Jones (defensive pass interference) and Carlton Davis (DPI) on third or fourth down.

Buffalo faced eight third downs during the five scoring marches and converted seven of them. Those conversions included two touchdowns: a scrambling Allen strike to tight end Dawson Knox on third-and-goal from the 14 and a Cook plunge on third-and-goal from the 3.

The Bills also went 5-for-5 in the red zone, excluding a series of game-ending kneeldowns, in a comeback reminiscent of the one they staged against the Cincinnati Bengals one week earlier. In that game, Allen and Co. scored three touchdowns in the final 7:33 of regulation to win 39-34. Buffalo also scored 16 points in the final four minutes of its season opener (a 41-40 victory over Baltimore) and closed its Week 14 win over Tampa Bay with a 14-0 fourth-quarter run.

The first Patriots-Bills meeting followed a similar script, as well. Consecutive Buffalo scoring drives tied that Week 5 game late before Andy Borregales won it for New England with a walkoff field goal.

“That’s kind of how a lot of their games have gone,” Patriots linebacker Jack Gibbens said. “If you watch them, when they’ve got great players over there, got the reigning MVP, they’re never out of it, and they were able to run it on us a little bit. We had them in some critical situations, just didn’t have to play that we needed to get off the field a couple times, and we were making those in the first half.”

In that first half, the Patriots outgained the Bills 283-76 and held a 16-5 edge in first downs. After halftime, Buffalo racked up 273 yards to New England’s 100 and 17 first downs to the Pats’ three. Cook rushed for 107 yards and two touchdowns at a 4.9 yards-per-carry clip, with 75 of those coming in the second half against a worn-down Patriots defense.

New England was playing without two of its most important defensive players in defensive tackle Milton Williams (ankle), who has yet to return from injured reserve, and linebacker Robert Spillane, who dressed for the game but did not play as he nursed a foot injury. Davis, a starting cornerback, also missed part of the second half with a groin issue before returning for the final three series.

The Patriots’ lone second-half stop — a three-and-out with less than three minutes to play — came too late. The Bills’ ensuing punt pinned the Patriots’ offense at its own 17-yard line, and Drake Maye’s fourth-down pass to Stefon Diggs was batted down by Joey Bosa. Buffalo picked up one first down three plays later to ice the game.

Asked about Allen, who threw three touchdown passes and added 48 yards on 11 carries, Vrabel quipped: “That’s why they pay him $60 million. I don’t know what to tell you. Just exactly what we knew it was going to be.”

Despite the loss, the Patriots remain in the driver’s seat in the AFC East at 11-3, one game up on the 10-4 Bills. Their defense will face another challenge next week against Lamar Jackson and the Ravens, who routed Cincinnati 24-0 on Sunday, but multiple players said this nosedive did not diminish their confidence.

“It’s still high,” edge rusher K’Lavon Chaisson said. “It’s still 10. No, that’s not changing.”

“I don’t think our confidence is shaken at all,” outside linebacker Harold Landry said. “I mean, we still had a chance to win the game, and we didn’t really execute, at all, at a high level, defensively, at the end of the game. But I don’t think our confidence is shaken at all. Like I said, this is just an opportunity for us to come in, learn, really look at ourselves and just improve.”