BUFFALO, New York -- The Bengals-Bills rematch coming next week almost didn't happen.
Both teams squeaked past undermanned opponents on Sunday, beating backup quarterbacks to advance to the AFC divisional round.
First, the Bills blew a 17-0 lead against Miami and had to rally for a 34-31 victory. Then, the Bengals were 1 yard from trailing the Ravens in the fourth quarter before Sam Hubbard returned a fumble 98 yards for the decisive score, and Cincinnati barely held on for a 24-17 victory.
This time, the Bengals will visit Buffalo. They met in Cincinnati on Jan. 2, when the game was stopped after Bills safety Damar Hamlin collapsed in the first quarter and needed to be resuscitated on the field. Hamlin is home following a remarkable recovery.
The Bills (14-3) struggled against No. 7 seed Miami, a 13 1/2-point underdog. The Dolphins, who were down to rookie third-string quarterback Skylar Thompson, took a 24-20 lead in the third quarter when Josh Allen was strip-sacked and Zach Sieler scored on a 5-yard return.
But Thompson, a seventh-round pick starting his third game because Tua Tagovailoa and Teddy Bridgewater are injured, threw an interception on third-and-19 from his 8 that led to a short field and a go-ahead score for the Bills.
"It was a bad decision on my part," said Thompson, who was 18 of 45 for 220 yards with one TD and two interceptions. "Just got to know the situation we're in there. ... I just got to understand the situation there and just take yards and play field position there and not force something. That one hurts. But just got to learn from it."
Allen and the Bills were sloppy and out of rhythm despite racking up 423 yards. Allen threw two picks that led to 11 points before his fumble led to another touchdown.
"At the end of the day, all that matters is winning the game," Allen said. "If it's by one or by 100, these are one-week seasons now. Everything you got. It's win or go home."
The Bills have to play much better to beat the Bengals. Same goes for Cincinnati.
The Bengals (13-4) fell behind Baltimore 10-9 after leading 9-0. They were fortunate it wasn't 14-9 at halftime because the Ravens had a first down at the 3 and settled for a field goal.
With the score tied at 17 in the fourth quarter, the Ravens drove to the Bengals 1. But Tyler Huntley, filling in for the injured Lamar Jackson, lost the ball when he held it out and leaped at the goal line.
The Ravens had players behind Huntley in the backfield ready to push him into the end zone but the third-year pro decided to try to jump in.
"We just didn't execute it right," Ravens coach John Harbaugh said. "Tyler went over the top. It was designed for him to go low."
The Bengals couldn't generate anything on offense the rest of the game, punting three times and totaling 19 yards, allowing the Ravens to stay in.
Huntley had Baltimore driving at Cincinnati's 17 in the final minute before a holding penalty and incompletions set up a fourth-and-20 from the 27. Huntley's desperation pass into the end zone bounced off Ravens wideout James Proche's hands.
"Our defense really carried us in the fourth quarter," Bengals coach Zac Taylor said.
The Bengals will need Joe Burrow and the offense to get back on track after putting up just 234 total yards to have a shot against the Bills.
The Bengals have won nine in a row while the Bills have an eight-game winning streak. One streak will end next Sunday.
While the Dolphins and Ravens couldn't pull off upsets, Daniel Jones and the New York Giants had the right stuff against the Minnesota Vikings.
The 9-win Giants knocked off the 13-win Vikings 31-24 behind an outstanding performance from Jones, who threw for 301 yards and two TDs in his playoff debut. The Giants move on to face the No. 1 seed Philadelphia Eagles.
After Brock Purdy and the San Francisco 49ers routed Seattle to kick off wild-card weekend, the next four games were decided by one score. Tom Brady and the Tampa Bay Buccaneers host the Dallas Cowboys on Monday night to determine which team faces the Niners next.