Allen connected with receiver Tyler Kroft with 15 seconds left for his fourth and final touchdown pass of the day at Orchard Park, New York. He also added a rushing touchdown.
The Rams overcame a 25-point, third-quarter deficit and took a late 32-28 lead before Allen orchestrated the game-winning drive.
The Rams looked set to equal the third-largest comeback in NFL history and the biggest in franchise history when they scored 29 unanswered points in the second half.
"Probably just got too relaxed and that's on me," said Allen regarding the loss of the Bills' big lead. "I've got to be better for our team and our offense."
The Rams' four straight touchdown drives came off two Jared Goff touchdown passes, one Goff run and a one-yard run by Darrell Henderson to give the Rams the lead.
But Allen was able to regroup and rally the Bills as he completed 24 of 33 for 311 total passing yards on the day.
Running back Devin Singletary rushed 13 times for 71 yards while also catching four passes for 50 yards for the Bills, who improved to 3-0 in the young season.
Goff completed 23 of 32 passes for 321 yards and two touchdowns. Henderson had 20 carries for 114 yards and a touchdown.
"We were just one step away, and unfortunately in this league that's not good enough," Rams safety John Johnson said. "The whole game was a weird game."
Eagles kicker Jake Elliott lined up for a potential game-winning 59-yard field goal with 19 seconds left, but guard Matt Pryor false started on the play which took the them out of field goal range. They opted to punt instead of trying for a 64-yarder.
Quarterback Carson Wentz was 29 of 47 for 225 yards, one touchdown and two interceptions.
Rookie quarterback Joe Burrow led the Bengals by passing for two touchdowns. He completed 31 of 44 passes for 312 yards.
The Bengals were led by rookie quarterback Joe Burrow, who finished 31 of 44 for 312 yards and two touchdowns. Tee Higgins caught both of the touchdown passes.
Meanwhile, Nick Foles completed three touchdown passes in the fourth quarter as the Chicago Bears came from behind to beat the Atlanta Falcons 30-26 to remain unbeaten after three weeks of the season for the first time in seven years.
Foles completed the rally with a go-ahead, 28-yard touchdown pass to Anthony Miller with 1:53 remaining. Bears safety Tashaun Gipson made an interception on the Falcons' next drive to seal the victory.