MIAMI GARDENS, Fla. — Amid the dancing and screaming and hugs and high-fives in the Buffalo Bills’ locker room, defensive tackle Kyle Williams watched his two young sons climbing around in his stall.

“What do you think, boys?” Williams shouted. “Where are we going? The playoffs? Yeah!”

His sons are only 6 and 4. For their father and most Buffalo fans, Sunday was a long time coming.

The Bills ended the longest current playoff drought in North American pro sports, making the postseason for the first time since the 1999 season. They avoided elimination by beating Miami, 22-16, and clinched an A.F.C. wild-card berth minutes later when Cincinnati rallied past Baltimore.

The Bills watched the finish of the Bengals game on locker room televisions, and then erupted.

“Everybody went crazy,” said Williams, who is in his 12th and perhaps final season with the Bills. “I’ve been a wreck for 10 to 15 minutes.”