EAST RUTHERFORD, N.J. -- The New York Jets defense was battered all game, with the Buffalo Bills primed for an upset. One big hit and one favorable bounce kept New York in control of its playoff destiny. Abram Elam sacked J.P. Losman and Shaun Ellis picked up the fumble and rumbled 11 yards into the end zone with less than 2 minutes left to give the Jets the go-ahead score for a critical 31-27 victory Sunday. The Jets (9-5) entered in a three-way tie with Miami and New England, but hold the tiebreaker. The Dolphins beat San Francisco 14-9 to keep pace with the Jets, while the Patriots played at Oakland later Sunday. With Buffalo (6-8) nursing a 27-24 lead and appearing close to wrapping up its first win against an AFC East opponent, 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 and ran down the sideline for a touchdown with 1:54 left. It was a hectic scene as bodies flew everywhere near the end zone, with even referee Jeff Triplette getting knocked to the turf and appearing to take a bloody nose. He worked the rest of the game wiping his face with a towel. Buffalo got the ball back twice, with both drives ending on interceptions, including Losmans desperation heave as time expired that was picked off in the end zone by Kerry Rhodes. It didnt 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 Jacksons 11-yard touchdown run with 5:30 remaining. Losman, making his second straight start for an injured Trent Edwards, had marched the Bills down the field with four straight completions to get the ball to the Jets 20. Marshawn Lynch followed with a 9-yard run, and then Jackson powered into the end zone. He got hit by several Jets at the 3, but kept the pile moving for the go-ahead score. New Yorks defense, which allowed Lynch to run for 127 yards on 21 carries, came up big when it counted most. The Jets snapped a two-game losing streak and offset another shaky performance by Brett Favre. The veteran quarterback was 17-of-30 for 207 yards and a touchdown, but also threw two interceptions. 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 score got the fans cheering just minutes after they booed loudly when Steve Johnson caught a 2-yard pass from Losman to give Buffalo a 17-14 lead. Rian Lindell banked a kick just inside the right upright for a 48-yard field goal to make it 21-20 with 3:35 left in the third quarter. Jay Feely kicked a 31-yard field goal to put the Jets up 24-20. Then they got lucky when Leodis McKelvin took the ensuing kickoff 100 yards for a touchdown, but it was called back because George Wilson was holding on the return.