EAST RUTHERFORD, N.J. -- The New York Jets were facing a stinging loss that would've knocked them out of first place in the AFC East and severely damaged their playoff hopes.
A bad play call, a big hit and a lucky bounce changed all that in an instant.
Abram Elam sacked J.P. Losman from behind and caused a fumble, and Shaun Ellis picked up the ball and rumbled 11 yards into the end zone with 1:54 left to give the Jets the go-ahead score in a 31-27 victory Sunday.
"That play that Shaun makes and Abe makes, who knows?" quarterback Brett Favre said. "At the end, we may look back and say that could be one of those plays that catapulted us into something great."
Maybe, but the Jets (9-5) looked nothing like a playoff team for most of this one as the Bills' once-dormant offense prospered against New York's struggling defense.
Buffalo (6-8) was nursing a 27-24 lead and close to wrapping up its first win against an AFC East opponent when Losman dropped back to throw and was hit from behind by a blitzing Elam. The ball squirted out and bounced around before Ellis grabbed it, tiptoed down the sideline and splashed into the end zone.
"I just kept running, got some good blocking and was able to get into the end zone," Ellis said.
The big play came as Ellis is dealing with legal troubles. He was arrested Nov. 29 and charged with possession of marijuana, speeding and driving without insurance after being pulled over by police in Hanover, N.J.
"Shaun has been Shaun, he hasn't changed," Favre said. "You find out a lot about people in tough times. If anything, guys rallied around him. It was good for this team that that play happened. And it was good for Shaun."
The Jets were surprised the Bills were passing in that situation, expecting Buffalo to try to run out the clock. After all, Marshawn Lynch gained 127 yards on 21 carries and New York was struggling to stop him. Instead, coach Dick Jauron overruled offensive coordinator Turk Schonert.
"Clearly the responsibility for the last call, the play-action pass, that was mine," Jauron said. "That goes right on me. It backfired clearly and caused us to lose the game. ... It's one of those times in a game that's pretty good for a pass, right before the 2-minute."
Jauron refused to blame Losman, making his second straight start for the injured Trent Edwards.
"It's on my shoulders to protect him, to keep him from that situation," Jauron said, "and I didn't do it."
It was a hectic scene as bodies flew everywhere near the end zone, with even referee Jeff Triplette getting knocked to the turf face first by Bills center Duke Preston and taking a bloody nose. He worked the rest of the game wiping his face with a towel.
Triplette said Preston sought him after the game to check on him and apologize.
"He's a really classy young man because he came to the locker room afterward and wanted to know if I was OK," Triplette said. "Whoever No. 75 is, he's a really classy young man. He wanted to know if I was OK."
Buffalo got the ball back twice, with both drives ending on interceptions, including Losman's desperation heave as time expired that was picked off in the end zone by Kerry Rhodes.
"It's been that type of season," receiver Lee Evans said. "Sometimes the ball bounces funny ways. On that last play, it certainly took a bounce for the worst for us."
The Jets remained tied atop the division with Miami, which beat San Francisco 14-9, and New England, which routed Oakland 49-26.
It didn't appear likely that the Jets were going to be doing any celebrating after this one, especially when the Bills -- held to single field goals in their previous two games -- went ahead on Fred Jackson's 11-yard touchdown run with 5:30 remaining.
Losman marched the Bills down the field with four straight completions to get the ball to the Jets 20. Lynch followed with a 9-yard run, and then Jackson powered into the end zone despite being hit by several Jets at the 3.
The Jets snapped a two-game losing streak and offset another shaky performance by Favre. The veteran quarterback was 17-of-30 for 207 yards and a touchdown, but also threw two interceptions and misfired several times.
"Maybe I don't have the arm I once had," he said. "I don't know."
Losman was 24-of-39 for 148 yards and a score and was picked off three times.
Leon Washington gave the Jets a 21-17 lead on a 47-yard touchdown run with less than a minute left before halftime.
The Jets took a 7-0 lead on Jones' 2-yard touchdown run on their first possession. It was the eighth straight game he scored in, his 15th touchdown overall, and 13th rushing -- all franchise records.
Jones, who entered leading the AFC with 1,144 yards rushing, finished with 78 yards on 20 carries. ... Jets linebacker Vernon Gholston, the No. 6 overall pick, was inactive for the first time. ... Jets safety Eric Smith played for the first time in seven weeks after suffering three head injuries in four games. ... Bills rookie wide receiver James Hardy left early in the first quarter with an injured left knee and didn't return. Jauron was unsure of the severity of the injury, but said, "We'll have to remain optimistic."
NFL Insider Mike Sando looks at the numbers behind Tyrod Taylor's contract.
It's no surprise the Texans came to terms with their entire rookie class, but DeAndre Hopkins' long-term deal prospects are still unsettled.
At age 30, receiver Stevie Johnson should see plenty of targets in 2016 -- as long as he can stay healthy.
Retired WR Calvin Johnson agrees with QB Matt Stafford that the Lions should be less predictable and tougher to defend this season.
Asked Saturday at a charity bowling event if the Bills' medical staff would allow him to practice early in training camp, wide receiver Sammy Watkins told ESPN, "You never know."
Jeremy Fowler weighs in on who needs to step up for the Ravens offensively with many of their key players recovering from injuries.