DETROIT >> Josh Allen took a shotgun snap, moved up in the pocket and backed up, rolled left and threw right.

It was just another play, a 28-yard pass to James Cook, in the latest sensational performance by the potential NFL MVP.

Allen ran for two scores in the first quarter and threw two touchdown passes in the second half, leading the Buffalo Bills to a 48-42 victory Sunday that snapped the Detroit Lions’ franchise-record 11-game winning streak.

“Scramble drills are one of our best plays,” Allen said.

He has a lot to do with that.

Allen was 23 of 34 for a season-high 362 yards with touchdown passes to Khalil Shakir and Ray Davis. He ran 11 times for 68 yards and two scores a week after being the first NFL player to throw and run for three touchdowns in a regular-season game.

“He poses a huge issue,” Detroit coach Dan Campbell said.

The AFC East champion Bills (11-3) have won eight of nine, including a victory against the two-time defending Super Bowl champion Kansas City Chiefs.

“It’s rare air up there with the best teams,” Buffalo coach Sean McDermott said. “That’s how we’re going to have to play every week moving forward.”

Jared Goff matched a career high by throwing five touchdown passes for the NFC North-leading Lions (12-2).

Buffalo extended its franchise record with 30-plus points in its eighth straight game and scored the most points against Detroit this season.

Coming off a 44-42 setback against the Rams, the Bills were not as effective on defense.

Goff’s fifth TD pass came with 12 seconds left when he connected with Jameson Williams from 3 yards with 12 seconds left, but the Lions couldn’t recover the onside kick to set up a game-ending Hail Mary try.

Allen threw a 33-yard pass to Ty Johnson on his second snap and converted a third down with another throw to the former Lions running back, picking up another 24 yards, after rolling right and showing patience before passing to set up a 1-yard sneak.

McDermott chose to go for it on fourth-and-2 from his 49 and Allen found Johnson wide open for a 31-yard catch to set up James Cook’s 6-yard touchdown run to restore a two-touchdown lead midway through the second quarter.

Campbell was aggressive as usual on the next drive, keeping the offense on the field with a fourth-and-4 from the Bills 46. Goff validated the decision with a 21-yard pass to Amon-Ra St. Brown to set up a 9-yard touchdown pass to lineman Dan Skipper.

Just when it looked as though the Lions might get routed in the second half, Goff converted a third-and-17 with a 66-yard TD pass to St. Brown.

After Jahmyr Gibbs scored his first of two touchdowns early in the fourth quarter to pull Detroit within 10 points, Campbell opted for an onside kick that Buffalo’s Mack Hollins returned 38 yards to set up another score for the Bills.