FOXBOROUGH, Mass. — Out of the mess, there was light. Out of the despair, there was hope. A few steps away from the abyss, the Jets had put together the kind of night that is supposed to matter in the NFL, that is supposed to yield satisfaction.

Zero turnovers. Dominant time of possession: 40 minutes and 54 seconds to 19:06, numbers eerily reminiscent of the way a Giants team had once upon a time played keep-away with a powerful Bills team all the way to a Lombardi Trophy.

And out of all of this, a chance, a prayer, a hope: the football sitting on the New England 40-yard line, five seconds left, the most dependable kicker in football lining up for what would have been a career-best 58-yarder to win the game and stun Gillette Stadium into silence.

“After almost 60 minutes, we had the ball and we had the game in our hands,” wide receiver David Nelson said. “That’s really all you can ask for.”

“It felt good off my foot,” Nick Folk said. “It felt really good.”

But this is a year when almost perfect doesn’t mean a thing, not for the Jets, certainly not yet. Later, for the second week in a row, Rex Ryan raged, “You hope at some point things even out.”

Of course, that’s exactly what most of the people inside the stadium believed had happened. Folk needed some extra octane to get the ball home; that meant keeping it lower. And that meant before it could sail through the air and break New England’s heart, it collided with the hand of a Patriots defensive tackle named Chris Jones.

If that name sounds familiar, it should: last year, Jones was whistled for an obscure penalty when Folk was attempting a 56-yarder in New Jersey that sailed wide. Jones was called for pushing the pile. Folk made the most of the mulligan. And now, 11 months later, things really had evened out.

Just not as Ryan wanted.

“At times,” he said, “we look like we’re good enough to win.”

And then his mood darkened on a dime.

“And then we make too many mistakes,” he said.

Ryan spoke with bile in his voice and salt on his tongue, a coach who knows well it is getting late early for his tenure in the chair.

And the Jets played with the purpose of a team that understood it needed to win or face the prospect of running the table to keep itself relevant.

And it wasn’t enough. The final was 27-25, and the Patriots sped merrily off the field, comfortably ensconced in their usual perch atop the AFC East, and the Jets stormed off the field realizing that even on a night when they played as close to a game plan as a team can play, it wasn’t enough.

“They gave us all we could handle,” Tom Brady said. It was meant as a compliment. It was no consolation prize.

“I’m a little upset our record is what it is,” Ryan seethed, the record now 1-6 and the mission every bit as simple as it is hopeless: start winning and hope you don’t stop. Aim for nine wins in nine weeks when there only has been one in the first seven. Yikes.

“They were almost perfect,” Brady said.

But almost was enough to pour gasoline on one more lost night in a lost season. As good as the offense was, as careful as Geno Smith was with the ball, as dominant as the running game was, there were too many possessions that ended with field goals and not touchdowns, thanks to dropped passes and killer penalties.

As stubborn as the Jets’ defense was, there was a quick Pats touchdown just 89 seconds into the game, and then an inexcusable one much later, on third-and-goal from the 19. And, yes, as good as a job as Ryan did getting his scuffing team ready to play on short rest, there were two wasted timeouts in the second half, neither of which he could fully explain afterward, both of which reflect poorly on the boss.

Preserve just one of them, maybe the Jets have enough time to pick up 10 extra yards at the end. And Folk can make a 48-yarder left-footed if necessary. But there were no extra yards, and no extra time. And now there is little in the way of hope left. The imperfect team pitched a near-perfect game. And it wasn’t enough.