ORCHARD PARK, N.Y. (AP) — Bills quarterback Josh Allen overcame questions about his accuracy and small-school pedigree to become the NFL’s second-highest paid player Friday.

Allen signed a six-year contract that locks him up through the 2028 season, and has a potential worth of $258 million, of which an NFL-record $150 million of the deal is guaranteed.

The Bills announced the signing, and a person with direct knowledge told The Associated Press of the contract’s value. The person spoke on the condition of anonymity because Allen and the team did not disclose those figures.

The total value and annual average of the deal ranks second in the NFL behind only Kansas City Chiefs starter Patrick Mahomes, who signed a 10-year, $450 million contract last year.

“It’s surreal to be in this spot right now,” said Allen in securing a quarterback position in Buffalo that’s been unsettled since since Hall of Famer Jim Kelly retired 25 years ago.

“I’m just thankful that we could get it done and now we can focus on going out there and earning it, and making sure they understand that I know they didn’t pay me for what I’ve done,” he added. “They did this because they expect me to continue what I’m doing, and expect me to go win this team some championships.”

The contract was signed a few days after general manager Brandon Beane said he wanted to get a deal done with the quarterback before the season or put talks off until next year so not to serve as a distraction.

The sides were in no rush. Allen was under contract through the 2022 season after the Bills in May picked up the player’s fifth-year option, worth nearly $23 million.

Beane said negotiations picked up late Thursday night, with the two sides agreeing to the parameters of the contract just before 4 a.m. Friday. The agreement was then reached after the team completed its training camp practice.

Allen is coming off a breakthrough season in which he set numerous franchise passing and scoring records in leading Buffalo to its first AFC East title since 1995 and deepest playoff run in 27 years. Buffalo’s season ended with a loss to Kansas City in the AFC championship game.

Kelly was fine with Allen breaking several of his single-season records, and could only imagine how many more might fall in the future.

“I’ll put it this way, if Josh Allen is with us for 10-plus years, he will be breaking his own records,” Kelly said last year. “I pull for him every time. ... I’m like a little kid.”

Allen’s production last year continued a trend of him making significant jumps in progress since the Bills traded up five spots in the draft order to select the quarterback with the seventh pick in the 2018 draft. Allen was the third of five quarterbacks drafted in the first round in 2018, and was knocked for accuracy issues during his three seasons at Wyoming.

The questions followed Allen through his first two seasons in which he ranked 32nd among NFL starters by completing less than 59% of his passes. Allen’s completion percentage jumped to 69.2 last year to rank fourth-best among NFL starters.

Allen has matured from a raw, strong-armed quarterback who had technique issues, and someone who relied too much on scrambling out of the pocket. Though he still remains a threat to run, Allen has been groomed to be more patient in the pocket.

Allen has benefited from a Bills front office that has assembled an experience group of receivers, over the past three years. It began with Buffalo signing Cole Beasley and John Brown in free agency in 2019, and continued the following offseason when the Bills acquired Stefon Diggs in a trade with Minnesota .

Diggs established immediate chemistry with Allen last year in becoming Buffalo’s first player to lead the NFL in yards receiving and catches.

Allen has also enjoyed stability at the coaching level in having spent his tenure in Buffalo working exclusively under head coach Sean McDermott and offensive coordinator Brian Daboll.

Daboll, this past week, praised Allen for his even-keel and competitive nature.

“Really, he’s the same guy he was when he walked in the door in terms of his mental approach,” Daboll said. “It’s well-documented, talk about Josh’s improvement. He’s a consistent guy for us. He’s the leader of our football team. He’s got his hands all over this offense. And his legs, too. Fortunate to have him.”