The Buffalo Bills haven’t made the playoffs since the 1999 NFL season. Had they missed out again this year, their postseason drought would be old enough to legally purchase cigarettes, and it would likely smoke those cigarettes in order to take the edge off from all that Bills football. Buffalo’s barren stretch is the longest such streak in North American sports, but, after a series of wonderfully unpredictable events on Sunday, it finally ended.

The Bills weren’t in control of halting their drought. Not only did they have to beat the Miami Dolphins on Sunday, to ensure a playoff berth they’d also need the Baltimore Ravens to lose—at home—to the down-and-out Cincinnati Bengals. The Bills kept up their end of the bargain, cruising to a 22-3 lead against the Dolphins by the fourth quarter, eventually winning 22-16. For most of the afternoon, the Bengals looked to be in a winning mood as well. They were throttling the Ravens 17-3 towards the end of the first half, and Baltimore appeared slow and out of ideas.

The Bills had hope, which, for most of the team’s history, has been something that exists for no other reason than to serve as the set-up line to a cruel joke.

Right on cue, the Bengals’ lead shrank. But then it swelled—hope!—before shrinking again. Of course. With 8:48 remaining in the fourth quarter, the Ravens’ Joe Flacco threw a touchdown pass to Mike Wallace, giving Baltimore their first lead of the afternoon. All they needed to do was hold onto that lead and Baltimore, and not the Bills, would be heading to the postseason. Cincinnati had nothing to play for, and they could be forgiven for rolling over. After all, they were prone to roll-overs even when things were going great.

Then, in a surprising turn of events, the witch, warlock, or otherwise undefined supernatural being who had been cursing and torturing the Bills for all these years decided to call it quits. The Bengals had one last drive, and on fourth-and-long with less than a minute remaining, Andy Dalton threw a 49-yard touchdown pass to Tyler Boyd.

Andy Dalton to Tyler Boyd for the #Ravens eliminating TD. #Bengals win Marvin Lewis’ (expected) final game as head coach and eliminate rival Ravens from the playoffs. #Bills officially take the final playoff spot. pic.twitter.com/TyH4UucQMI — Roberto Jurado (@JuradoNYC) January 1, 2018

For the first time in 17 seasons, the Bills are going to the playoffs.

This was a bizarre season for Buffalo. They weren’t supposed to be in contention for a playoff spot, but they kept eking out wins anyway. Even after their head coach benched the starting quarterback during a crucial game so he could play a young man who apparently had just started learning how to play football, the ship was calmly righted in time for Sunday’s showdown. They had a chance and they took it (with a little help from Cincinnati).

Things aren’t all sunshine and happiness for the Bills. LeSean McCoy, their dynamic running back, went down with an ankle injury and had to be carted off the field in Miami. If they are to add anything besides “participant” to their postseason resume this year, the Bills are going to need him in a big way.

But let’s not dwell on that. The Bills are going to the playoffs. They will be playing against the Jaguars in Jacksonville. No matter the result, it should be enjoyed like the rare celestial event it is. Who knows when Buffalo’s Comet will visit us again.

Update, Jan. 1, 2018: Via kicker Stephen Hauschka, here’s video of the Bills’ locker room celebrating the Bengals’ winning touchdown: