FOXBOROUGH, Mass. >> The New England Patriots concluded a bitter season on a high note.

It wasn’t enough to save their coach’s job.

Joe Milton III passed for a touchdown and ran for another in his professional debut, and the Patriots cost themselves the No. 1 overall pick in the NFL draft with a 23-16 win over the AFC East champion Buffalo Bills on Sunday. Shortly thereafter, owner Robert Kraft fired coach Jerod Mayo after one season.

“After the game I informed Jerod Mayo that he will not be returning as the head coach of the New England Patriots in 2025. For me, personally, it was one of the hardest decisions I have ever made,” Kraft said in a statement. “Unfortunately, the trajectory of our team’s performances throughout the season did not ascend as I had hoped.”

The Patriots (4-13) snapped a six-game skid when a loss would have guaranteed them the top draft pick. Instead, they fell to No. 4 behind Tennessee, Cleveland and the New York Giants.

Mayo held his postgame news conference before his firing was announced. He said draft position was not a focal point in the locker room heading into Sunday.

“I’ve said this over the last couple of weeks, as a player, as a coach, we always want to go out there and win,” Mayo said.

Milton finished 22 of 29 for 241 yards in relief of rookie Drake Maye, who played only one series. Kayshon Boutte had seven catches for 117 yards and a TD, and Joey Slye kicked three field goals.

New England had four healthy scratches and rested other key players, including running back Rhamondre Stevenson. Tight end Hunter Henry was inactive with a foot issue.

Describing what he called “an emotional” postgame locker room, Mayo said questions about his future would be addressed in due time. He may have already known that his time had ended.

“These guys have been turning the page, ignoring the noise, and just coming to work every day, and I’m very appreciative of that,” Mayo said. “Told them after the first win of the season, coaches are nothing without the players, and I just told them that again. ... Also told them, today it’s all about the game.”

Mitchell Trubisky was 15 of 21 for 101 yards for the Bills (13-4), who had already wrapped up the No. 2 seed in the AFC playoffs and rested most of their starters.

Quarterback and MVP candidate Josh Allen played one snap, handing off to James Cook to extend his streak of consecutive starts to 115 games, including the playoffs. Trubisky played until late in the third quarter, when he was replaced by Mike White.

Cook rushed for his 16th TD of the season to tie O.J. Simpson’s Bills franchise record.

The Patriots extended their lead to 23-16 with 1:55 left in the fourth quarter on a 50-yard field goal by Slye. The Bills then turned it over on downs when White’s pass fell incomplete.

Bills coach Sean McDermott quickly turned his focus to next week.

“Everything is earned and there’s nothing given in the playoffs,” he said. “And you’re going against the best every week, so we start with one week and really one day at a time and get back in here and find out when we play and take it one day at a time.”