EAST RUTHERFORD, N.J. — If you want to drive National Football League historians crazy, ask them when was the last time a team lost the turnover battle 4-0 and gave up a safety … and still WON the game.

It’s uncertain when it happened previously, but it absolutely occurred Sunday afternoon at MetLife Stadium before 78,523 witnesses as the Bills rallied from a 16-0 deficit in the final 18-plus minutes to beat the Jets, 17-16.

It was an unexpected win in the season opener, a bit lucky to be sure, but a hard-to-miss show of character for a Buffalo team that seemed doomed to start the campaign with an embarrassing loss.

The goat-turned-hero of the game was Bills’ second-year quarterback Josh Allen, who was perfectly awful in the first half.

How bad?

He turned the ball over four times in a span of 26 minutes – two interceptions, albeit both tipped, one producing a “pick six” TD, and two lost fumbles – was sacked once and had a microscopic 45.7 passer rating, though completing 15-of-23 throws.

Of course, his bacon was literally saved by his defense which held the Jets to a mere 104 yards total offense in the first half and sacked Allen’s counterpart, Sam Darnold, three times.

The 17-yard interception return for a touchdown by Jets linebacker C.J. Mosley plus a missed 45-yard field goal and botched extra point by New York kicker Kaare Vedvick left the Bills trailing only 6-0 at intermission.

BUT THE margin ballooned to 16 midway through the third period, the game turning on a dropped interception by Jets safety Marcus Maye, whose first-half pick was wiped out by a hold away from the play.

His drop kept alive a Buffalo drive that kicker Stephen Hauschka cashed with a 43-yard field goal.

Thus nudged, Allen took over in Buffalo’s first two final-period possessions.

First came an 8-play, 85-yard drive in which he scored on a 3-yard run. Then it was an 80-yard, 8-play possession that produced the game winner when Allen hit John Brown, the free agent from Baltimore, with a 38-yard scoring pass.

Afterward, coach Sean McDermott enthused, “What a blessing. The group in that locker room, I’m so proud of them. On the road, in the division, down like we were, momentum certainly not in our favor most of the game …”

Of Allen’s play after the nightmare first half, McDermott added, “ (That was) a young player coming in, keeping his poise and being mentally tough and then the players executed at a really high level.

“Early in the game we shot ourselves in the foot with a couple of costly penalties that took us out of points … and turning the ball over four times.”

OF COURSE, Allen had some help on offense.

Brown had a team-high seven catches for 123 yards and rookie third-round draft choice Devin Singletary had 70 yards on only four carries and added five catches for 28 more.

For the record he outplayed Le’Veon Bell, the free agent running back from the Steelers, who had 11 rushes for 60 yards and six receptions for 32.

“It was good to get him in the mix,” McDermott said of Singletary, who makes up for a lack of elite straight-ahead speed with tremendous elusiveness. “It wasn’t too big for him, which was great.”

To which Allen added, “One (of his runs) was an unbelievable cut … I don’t know how he did it, but that’s the kind of thing he brings to the table. He’s elusive .. very slippery … tough to tackle.”

Of the game-winning drive, he added, “I was trying to stay as calm as possible. (Late-game) situations we practice all the time, coach McDermott is great with situational football. It was just me trusting my eyes.

“I settled in during the fourth quarter and felt like I calmed down and let things come to me instead of forcing things.”

Including the game-winning connection to Brown with three minutes to play.

“It was a double move,” the wideout recalled, “and the defensive back (Darryl Roberts) had great position on the ball … Josh just made a perfect throw and I was able to come back to the ball.”

Of Brown, McDermott noted, “I really appreciate his unselfish approach. He never wavers, he’s extremely resilient, a team-first guy. I’m just happy that he could make a big-time play for us.”

But he also realizes his team was a bit fortunate and emphasized how much work has to be done before the Bills return to the Meadowlands to face the Giants (0-1) next Sunday.

“It’s hard to win in this league,” he said. “You go into some tough environments and we expected a 12-round fight. We expected this type of game and I thought our guys kept their composure and put together a good effort in the second half. They felt good at halftime … their morale was up.”

As for Allen’s maturation McDermott added, “You always want to be able to say you’ve done it one time … to bring a team back, not only at home, but also on the road against a division opponent. I think that’s a resume builder.

“He was very composed, he knew if we needed to hurry up or slow down. I thought (the comeback) was well-managed overall.”

Much to the Jets’ dismay.