ORCHARD PARK, N.Y. — Jay Ajayi ran for 206 yards and broke loose for a 57-yarder in overtime to set up Andrew Franks’s 27-yard field goal with 47 seconds left to lead the Miami Dolphins to a 34-31 win over the Buffalo Bills on Saturday.
In winning for the ninth time in 10 games, the Dolphins (10-5) inched closer to their first playoff berth since 2008.
Miami can secure the AFC’s final wild-card berth as early as Sunday if Denver loses to Kansas City. Denver needs to win its final two games to make the postseason.
The Dolphins host the Patriots in Week 17.
The Bills (7-8) were eliminated from contention and extended the NFL’s longest active playoff drought to 17 seasons. Buffalo’s drought is tied for the fifth longest in NFL history, and longest since the New Orleans Saints went 20 years before qualifying for the playoffs for the first time in franchise history in 1987.
Ajayi is the fourth player in NFL history to have at least three games with at least 200 rushing yards in a season. Earl Campbell, O.J. Simpson, and Tiki Barber are the others.
‘‘It’s about running hard through the whole game and finishing strong,’’ Ajayi said. ‘‘Division rival game, December game, a lot was on the line. Tensions were high today.’’
Franks forced overtime by hitting a career-best 55-yard field goal with six seconds remaining.
The Bills overcame a 14-point deficit three times before taking their first lead with 1:20 left. That’s when Tyrod Taylor converted a fourth-and-goal by completing a 7-yard pass to Charles Clay in the end zone.
The Bills squandered a scoring chance on the first possession of overtime when Dan Carpenter missed wide right from 45 yards with 10:03 remaining. Carpenter also missed wide right on a 46-yard attempt in the first quarter.
Two of Ajayi’s 200-yard games have come against Buffalo. He had a career-best 214 yards rushing and a score in the Dolphins’ 28-25 win over Buffalo at Miami on Oct. 23.
‘‘Like, come on,’’ Bills safety Corey Graham said in frustration. ‘‘I’ve never been part of anything like that. I’ve never seen anything like that. I don’t get it.’’
Though the Bills vowed to contain Ajayi, he broke loose on the first play from scrimmage on Miami’s second and final possession of overtime.
With Miami backed up at its 15, Ajayi took the handoff and stiff-armed defensive lineman Leger Douzable at the line of scrimmage in finding a crease off left tackle.
It didn’t help that the Bills only had 10 players on the field when Ajayi took off in overtime. No one took into account that cornerback Stephon Gilmore was pulled from the game and placed in concussion protocol.
Matt Moore finished 16 of 30 for 233 yards and two touchdowns and an interception in making his second consecutive start in place of Ryan Tannehill, who is out with a sprained left knee.
DeVante Parker caught a 56-yard touchdown pass and Kenny Stills scored on a 6-yard catch.
Backup running back Kenyan Drake also scored on a 45-yard run.
The Bills’ defense squandered what was a record offensive outing. Buffalo finished with 589 total yards to beat the previous team mark of 582, set against Miami on Sept. 1, 1991.
Taylor went 23 of 39 for a career-high 329 yards passing and three touchdowns. He became Buffalo’s first player to top 300 yards passing since journeyman Kyle Orton had 329 in a 26-24 loss at Oakland nearly two years ago to the day.
Sammy Watkins had 154 yards receiving and a touchdown.
LeSean McCoy had 128 yards rushing and also scored once.
The Dolphins appeared to be in control when Moore hit Stills for a touchdown to put Miami ahead, 28-14, with 3:14 left in the third quarter.
The Bills responded by scoring 17 points on their next three possessions.