ORCHARD PARK, N.Y. (AP)The injury-depleted Dolphins felt that few people gave them a chance to beat the three-time defending AFC East champion Bills in a wild-card playoff game on Sunday.

But despite the challenges, they almost pulled off the upset.

Led by rookie third-string quarterback Skylar Thompson, and playing without several offensive starters, the AFC’s seventh-seeded Dolphins rallied from an early 17-0 deficit before falling short in a 34-31 loss.

”You could tell there was no quit in us,” Thompson said. ”Walking out for this game, nobody gave us a chance at all. We had a chance to win it, and that’s what you want. It speaks volumes about the fight in this team, the guys we have in this locker room, the people we have in this organization, from top to bottom.”

After losing five in a row down the stretch, the Dolphins made the playoffs for the first time since 2016 under first-year coach Mike McDaniel with a win against the Jets in the regular-season finale and with help from the Bills, who eliminated New England.

But they entered the postseason without starting quarterback Tua Tagovailoa, who is in the NFL concussion protocol, and with backup quarterback Teddy Bridgewater limited by a dislocated pinky finger.

The Dolphins also were without leading rusher Raheem Mostert (broken thumb), left guard Liam Eichenberg (hand), and right tackle Brandon Shell (knee/ankle).

”That was the situation at hand,” McDaniel said. ”That was the hand that was dealt. And that was the part of the story that we were willing to complete.”

They almost did it again Sunday in a frenzied environment against a Bills team with Super Bowl aspirations that hasn’t lost a playoff game on its home field since the 1996 season.

After falling behind 17-0, Miami scored three field goals, a touchdown, and a 2-point conversion in a 7:01 span to tie the game just before halftime.

Then in the first minute of the third quarter, Zach Sieler recovered Josh Allen’s fumble forced by Eric Rowe and returned it 5 yards for a touchdown that gave the Dolphins a 24-20 lead.

”It was almost surreal,” Sieler, a defensive end in his fifth season, said about scoring his first NFL touchdown. ”It’s something you dream about.”

Cornerback Xavien Howard and safety Jevon Holland also had interceptions of Allen in the second quarter that led to 11 Miami points. Also benefitting from a 50-yard punt return by Cedrick Wilson Jr., the Dolphins needed to gain only 82 yards on their four scoring drives before halftime.

Sieler had two of Miami’s playoff-record seven sacks.

”We had some ups and downs. But I think we found our way,” Sieler said. ”We made the plays when we needed to. We got to the playoffs. That was the goal. We just couldn’t finish today.”

After pulling within three points on Jeff Wilson’s 1-yard run with 10:53 left, the Dolphins never crossed midfield again on their final two possessions. Miami’s chances ended with Thompson failing to connect tight end Mike Gesicki on fourth-and-6 with 2:22 left, allowing Buffalo to run out the clock.

A season that began with a promising 3-0 start and 8-3 record going into December, ended with the Dolphins losing six of their final seven games.

They have not won a postseason game since 2000.

”We are very aware of the drought of winning a playoff game,” McDaniel said.

”That’s something that, since I’ve got the job, has been a huge motivating factor for me, that I really wanted to bring the team, the organization, and the fanbase” the first-year coach added. ”We fell short, but it wasn’t because of lack of effort, or lack of determination, or lack of intent. It’s because we didn’t get it done. We are a young team. We had to learn from it. Unfortunately, we had to learn the hard way.”

The Dolphins displayed resilience in coming back from 21 points down twice in a 42-38 win against at Baltimore on Sept. 18, and with a 14-point comeback at Detroit on Oct. 30.

”Man, our defense played so good today,” Thompson said. ”That’s tough. Because those guys gave us a every chance to win. Guys got us a touchdown, got us turnovers, helped me out a ton. And for us to not come out with a win hurts me a lot.”

AP NFL: https://apnews.com/hub/nfl and https://twitter.com/AP-NFL