Rex Ryan has been fired as head coach of the Buffalo Bills, the team announced Tuesday morning.

The bombastic former Jets coach went 15-16 in most of two seasons, finishing in third place in the AFC East in consecutive years. He was failed to end the Bills’ NFL-longest playoff drought, which was extended to 17 seasons.

“I spoke with Rex earlier today and we mutually agreed that the time to part ways is now. These decisions are never easy. I want to take this opportunity to thank Rex for all his efforts and wish him all the best moving forward,” Bills owner Terry Pegula said in a statement. “[Wife] Kim and I and our entire Bills organization share in the same disappointment and frustration as our fans, but we remain committed to our goal of bringing a championship to Western New York.”

The timing is notable: with just one game remaining in the season, against Ryan’s exes, the Jets. NFL Network reported Ryan felt it was inevitable and wanted to get it over with.

The axing comes in the wake of an overtime defeat to the Dolphins on Dec. 24 that was littered with questionable strategic decisions and one particularly embarrassing moment when the Bills only had 10 players on the field for a crucial play on defense.

“Obviously, reviewing the film, that’s about as painful of a loss as I can remember,” Ryan said at a press conference Monday. “This is obviously the toughest defeat that I’ve taken to this point as a Bills coach. They all hurt, but this one especially.”

Ryan was asked specifically whether the Pegulas would see Saturday’s loss as sealing his fate.

“Whatever they think is fair, that’s the only thing that matters,” Ryan said. “But if it is, it’s something I’ve got to live with.”

Ryan, 54, leaves with a record of 61-66 (plus 4-2 in the playoffs) in eight seasons as a head coach, the first six with the Jets — when he became one of the most visible figures in the NFL for his cocky, sometimes profane sound bites and animated sideline demeanor.

His next move is unclear, though many have speculated he’s a natural fit for a spot on a television studio show.

Ryan’s twin brother, Rob, also was let go from his job as an assistant coach. Offensive coordinator Anthony Lynn will be the Bills’ interim head coach for Sunday’s season finale against the Jets at MetLife Stadium.