ORCHARD PARK, N.Y. (AP) — Josh Allen might get the credit for saving the Buffalo Bills from a monumental second-half meltdown. The third-year starter was more upset that he helped put the team in that position to begin with.

Two second-half turnovers led to the Los Angeles Rams rallying from a 25-point deficit, but Allen bailed the Bills out by completing a 3-yard pass to tight end Tyler Kroft with 15 seconds remaining to secure a 35-32 win on Sunday.

“Yeah, probably just got too relaxed and that’s on me,” said Allen, whose five-touchdown outing (including one rushing) was clouded by two turnovers that led to Rams TDs.

“I’ve got to be better for our team and our offense,” he added.

“I can’t throw and interception, and I can’t fumble the ball, and then lose my cool like that,” he said, referring to a 15-yard unsportsmanlike conduct penalty that nearly ended Buffalo’s final drive. “But we bounced back. Proud of our guys.”

The game appeared to be a blowout once Allen hit Stefon Diggs for a 4-yard pass to put Buffalo up 28-3 with 8:05 left in the third quarter. It ended up being a nail-biter.

Jared Goff led the Rams to score on four consecutive drives, and LA took the lead on Darell Henderson’s 1-yard run with 4:30 remaining.

Allen responded by marching the Bills on a 11-play, 75-yard drive. He hit Cole Beasley for 16 yards on third-and-25, and then got help from a pass-interference penalty against Darious Williams on fourth-and-7.

One play later, Allen had time to drop back and wait for Kroft to cut across the middle. Watching as Kroft got a step past linebacker Micah Kiser, Allen lofted a pass, which the tight end reached up and caught before tumbling to the ground for his second TD of the game.

Buffalo has won its first three games in consecutive seasons, the first time the franchise has done that since 1991-92 and the third time overall.

The Rams (2-1) failed to match what would’ve been the third-largest comeback in NFL regular-season history. They blamed themselves for digging such a deep hole. But they also were unhappy with the officials either for the call against Williams.

“We were just one step away, and unfortunately in this league that’s not good enough,” safety John Johnson said. “The whole game was a weird game.”

As for the penalty against Williams, Johnson said “it was the wrong call,” before adding: “You can’t narrow it down to just one call.”

“Disappointing end to a very resilient effort by our guys,” Rams coach Sean McVay said. “I love this football team. We’re not going to make any excuses. We’re going to use this as an opportunity to move forward.”

Kroft played a role in Allen's interception. He made a leaping catch but had the ball stripped from his arms by Johnson. But Kroft, who has spent the past two seasons bothered by foot and ankle injuries, ultimately capitalized while filling in for injured starter Dawson Knox, who was sidelined by a concussion.

“Obviously, there’s emotion that’s been brought into this,” Kroft said. “Playing on two bad feet last year, there was a lot of stuff to overcome personally. ... I’m just happy I was in a position to make a play today.”

Allen finished 24 of 33 for 311 yards with four touchdown passes and also scored on a 1-yard run. He’s had a hand in 12 touchdowns, the most in team history through the first three games of the season. Hall of Famer Jim Kelly held the record of 10, set in 1991.

It was the eighth successful fourth-quarter comeback for Allen in his three seasons. Last week, the Bills overcame a 20-17 fourth-quarter deficit to beat Miami 31-28.

Goff went 23 of 32 for 321 yards with two touchdowns and an interception.

Aaron Donald had two sacks and also forced an Allen fumble, which he recovered at the Bills 37. The recovery led to Henderson’s touchdown, which put the Rams up 32-28.

“I thought we had it,” Donald said “I thought we came together, rallied together and tried to find a way to win. We came up short, obviously. Can’t make those mistakes early.”

DIGGS DENIED

Diggs was denied a touchdown on consecutive plays from the Rams 1 late in the first quarter. He first scored on a 1-yard catch, but the play was overturned upon video review, with officials ruling Allen’s pass hit the ground. Allen then found Diggs wide open in the end zone, but the touchdown was overturned by offsetting flags, with a holding penalty called against guard Brian Winters.

ANTHEM

Rams: At least 13 Los Angeles players, including Donald, knelt along the sideline during the anthem.

Bills: Buffalo players continued their season-long decision to stay inside the locker room for the anthem.

INJURIES

Rams: S Jordan Fuller did not return after sustaining a shoulder injury in the first half.

Bills: WR John Brown injured a calf in the first half and did not return. ... S Micah Hyde hurt his left ankle in the fourth quarter, but returned after missing just one play.

UP NEXT

Rams: Host the New York Giants next Sunday.

Bills: Make the first of three West Coast trips, playing at the Las Vegas Raiders next Sunday.

___

More AP NFL: https://apnews.com/NFL and https://twitter.com/AP_NFL

Copyright 2020 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed without permission.