KANSAS CITY, Mo. -- Sean McDermott thought for a moment that a difficult week for himself and the Buffalo Bills would end with one last gut punch, an audacious touchdown pass by the Kansas City Chiefs with just over a minute left to steal a win Sunday.
Then the Bills' coach saw the yellow flag on the field.
The pass from Patrick Mahomes to Travis Kelce, which was then lateraled across the field to Kadarius Toney, for the 49-yard score was called back by an offside penalty on none other than Toney himself.
And when the Bills proceeded to hold the Chiefs on downs, they escaped from Arrowhead Stadium with a heart-stopping and head-scratching 20-17 victory.
"As the play unfolded," McDermott said, "Kelce got wide open. The play after he caught the ball, I've never seen a play like that in the NFL. But I saw the referees signaling that direction. I didn't know if it was a pick or what. It turned out to be offside."
Rarely is offside called on an offensive player. But replays showed that Toney's foot was clearly across the line of scrimmage.
That didn't make the call sit any better with Mahomes, who chased after three different officials for an explanation. Or with Chiefs Coach Andy Reid, who was still incensed after walking out of the locker room afterward.
"It's a bit embarrassing for the National Football League for that to take place," Reid said.
It was the second consecutive week the Chiefs (8-5) were dealing with questionable officiating. Last week in Green Bay, they were left wondering why pass interference was not called on a pass intended for Marquez Valdes-Scantling in the closing minutes of that game.
"Loss for words, man," Mahomes said. "To end another game and we're talking about referees, it's bad for the NFL."
It was good for the Bills (7-6), though, and they sure needed something positive to happen.
The Bills' Josh Allen threw for 233 yards with touchdowns running and throwing, though he also threw an interception for the ninth consecutive game. James Cook had 58 yards rushing and caught five passes for 83 yards and a score.
The Bills had been 2-6 in games decided by six points or fewer, and they had lost a lead in the final two minutes in three losses.
"It wasn't the prettiest of wins. We all know that," Allen said. "But the defense played fantastic."
Mahomes finished with 271 yards passing and a touchdown with an interception, and Rashee Rice had seven catches for 72 yards and the score. But it wasn't enough to keep the Chiefs from losing for the fourth time in six games.
"It's a gut check," Chiefs guard Trey Smith said. "You got to dig down deep. We still have games left to play."
The Chiefs continued a recent track record of lousy starts on Sunday. Mahomes was intercepted by A.J. Epenesa on their first series, they punted on each of their next three, and it wasn't until the closing minutes of the first half that Kansas City was able to sustain a drive that ended with Jerick McKinnon's touchdown run.
By that point, the Bills had already reached the end zone twice.
The first touchdown came when Cook was unchecked coming out of the backfield, caught a flick from Allen and breezed 25 yards for the score. The second came at the end of a 73-yard drive, when Allen kept the ball over the right side and was stood up at the Kansas City 4, only for the entire Bills offense to gather behind him and shove into the end zone.
Buffalo added a field goal out of halftime, but momentum quickly tilted Kansas City's way. Mahomes led a nine-play, 75-yard march that ended with Rice's touchdown catch, then their defense forced back-to-back punts, before another drive ended with Butker's tying field goal with 11 1/2 minutes to go.
The Bills had one last scoring drive in them, which ended with Tyler Bass' go-ahead field goal with 1:54 left in the game.
The Chiefs thought they did, too, until they saw a penalty flag on the field.
"I've played seven years in the National Football League and never had offensive offside called," Mahomes said, still seething in his postgame news conference. "You wait until a minute left to make a call like that?"