ORCHARD PARK, N.Y. (AP) — Sam Darnold one-upped fellow rookie Josh Allen, rallying the New York Jets to a 27-23 win over the Buffalo Bills on Sunday.

Elijah McGuire scored on a fourth-and-goal run from the 1 with 1:17 remaining to cap a drive during which Darnold completed three of five passes for 52 yards. The rookie quarterback particularly showed off his deft touch on a 37-yard pass to Robby Anderson, who made an over-the-shoulder catch up the right sideline.

It was Darnold's first career fourth-quarter comeback and came in his first game back after missing three with a strained right foot.

He finished 16 of 24 for 170 yards with a touchdown and interception. The Jets (4-9) snapped a six-game losing streak, and bounced back a week after squandering a 16-0 lead in a 26-22 loss at Tennessee.

Darnold, drafted third overall, got the edge on Allen, who was selected with the seventh pick.

Allen went 18 of 36 for 206 yards and two interceptions, both picked off by Trumaine Johnson, including one on the Bills' final drive to seal the Jets victory.

Allen did finish with 101 yards rushing to become just the second quarterback in NFL history to top 90 yards rushing in three consecutive games, joining Tobin Rote, who did that with Green Bay in 1951.

Buffalo dropped to 4-9 in what proved to be a sloppy game.

The Jets won when embattled coach Todd Bowles elected to gamble after Darnold was stopped at the 1 on third-and-goal from the 4.

McGuire scored by taking a handoff and running to his right before finding a crease to squeeze his way into the end zone. He finished with 60 yards and was playing in place of starter Isaiah Crowell, who left with a shoulder injury in the second quarter.