CHICAGO (AP) — AJ McCarron couldn't remember having this much fun at any level of football.

Trailing by five in the closing minutes, he told his teammates they were going to pull out the win and it would be a "legendary" moment for them.

McCarron delivered in the end after struggling for most of the game, leading a fourth-quarter surge that culminated with a touchdown pass in the final minute, and the Buffalo Bills closed the preseason with a 28-27 victory over the Chicago Bears on Thursday night.

With both teams holding out their starters and few key reserves playing, the focus was on McCarron. For most of the game, he made a shaky case for a roster spot let alone a starting job, but he did come through down the stretch.

He ran for a touchdown and threw for three more in the fourth — including a 6-yarder to Keith Towbridge in the closing minute. That capped an 84-yard drive that was aided by two roughing-the-passer calls, including one against Isaiah Irving on a fourth down at the Buffalo 3.

"I looked at the group and told them, 'Watch this, it's gonna be legendary,'" McCarron said. "First, I said, 'Watch this, we're gonna go down and win and you're gonna remember this for a long time so this is gonna be legendary — for us and for our group, not knowing who's (gonna be) here tomorrow.' ... It was just awesome to battle with them and probably the most fun I've ever had."

McCarron was 13 of 34 for 156 yards and had an interception returned for a touchdown in the early going. He could be the odd man out if the Bills opt to go with two quarterbacks rather than three, though coach Sean McDermott insisted he is "absolutely" in the race for the starting job with first-round pick Josh Allen and returning backup Nathan Peterman.

He also said he has not decided who will start the opener at Baltimore on Sept. 9.

CASE TO STAY

Tyler Bray made a case for the Bears to keep three quarterbacks. With Mitchell Trubisky and backup Chase Daniel not playing, Bray was 19 of 29 for 180 yards and an interception. Ryan Nall ran for 79 yards, including a 32-yard touchdown.

"I like where we're at," said Bears coach Matt Nagy, in his first season. "We've got a lot of depth and we're going to have some tough decisions here coming up."

Signed to a two-year deal in free agency after spending the past four seasons as Andy Dalton's backup in Cincinnati, McCarron was considered the initial front-runner for the Bills' starting job because he had more experience than Allen and returning backup Peterman.

But he missed a little over a week after he bruised his right shoulder while being hit several times at Cleveland on Aug. 17. That injury along with his performance seemed to knock him out of the running for the starting job. It also raised questions about whether he will make the opening roster.

But McCarron said he has "no clue" where he stands in the competition or if he'll make the roster.

"I understand you all want to talk about the QB competition, but I'm enjoying the game," he said.

SLOW START

McCarron got off to a brutal start, throwing for just 39 yards and getting picked off twice in the first half.

His troubles really began after Cody Parkey kicked a 47-yard field goal on Chicago's first possession.

Moments later, McCarron threw a pass right to the Bears' Doran Grant along the sideline, resulting in a 33-yard touchdown return . And just like that, it was 10-0.

Parkey added a 23-yard field goal midway through the second quarter. Nall made it 20-0 with just under two minutes left in the half with his 32-yard TD run up the right sideline, though the Bears missed another opportunity in the closing seconds after McCarron got picked off again.

Chicago's Abdullah Anderson tipped a pass at the line, leading to an interception for John Timu. But Parkey's 39-yard attempt hit the right upright.

NATIONAL ANTHEM

There were no protests by either team during the anthem.

INJURIES

Bills: WR Ray McCloud III suffered a knee injury.

Bears: TE Daniel Brown suffered a shoulder injury on a 27-yard catch in the third and left the game. Nagy said he's not sure if it's "day by day or week by week." ... LB Kasim Edebali was helped off the field and taken from the sideline on a cart with a bruised leg after a run by Buffalo on the first play of the fourth quarter.

NEXT UP

Bills: Open season at Baltimore on Sept. 9.

Bears: Open season at Green Bay on Sept. 9.

___

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