FOXBOROUGH, Mass. — Sunday night’s nationally televised matchup between the Chiefs and the Patriots could have been portrayed as a passing of the torch with 23-year-old Patrick Mahomes threatening to supplant Tom Brady, 41, as one of the top quarterbacks in the NFL.

The only problem was somebody forgot to tell Brady.

In a game with zero punts, Brady out-dueled the rising star in a back-and-forth shootout that ended with Stephen Gostkowski kicking a 28-yard field goal on the final play to give the Patriots a 43-40 victory at Gillette Stadium.

It was the Chiefs’ first loss of the season following five straight wins, while the Patriots improved to 4-2 in capturing a game that could prove critical when it comes to playoff seeding.

“It’s tough to slow those guys down,” Brady said of the high-powered Chiefs, who rallied from a 24-9 first-half deficit. “They’re going to be pretty tough to stop. I’m glad we had our last shot and glad we took advantage of it.”

Mahomes lived up to the hype completing 23-of-36 passes for 352 yards and four touchdowns, all in the second half. He did have two interceptions. Brady, meanwhile, was just as good, going 24-of-35 for 340 yards while throwing for one touchdown and running for another.

The Chiefs tied the score 40-40 on an explosive 75-yard touchdown catch-and-run by Tyreek Hill with 3:03 remaining in a game that produced 946 combined total yards. That was plenty of time for Brady. He used every second in moving 65 yards in seven plays with the highlights being a 16-yard completion to James White and 39-yarder to tight end Rob Gronkowski to the Chiefs’ 9. Two plays later, Gostkowski kicked the game winner, his fifth field goal of the night.

“We had control then we let them back in the game,” Brady said. “They were making plays on offense and then we were making plays. We talked about competing for 60 minutes and that’s what it took.”

Mahomes was trying to become the sixth quarterback since 1970 to win each of his first seven career starts, while Brady earned his 200th career regular-season victory.

The Patriots’ Hall of Fame-bound quarterback spent the first half scoring touchdowns while the Chiefs settled for field goals as the hosts built a 24-9 halftime lead. With 10 days to prepare for Kansas City’s creative and explosive offense, the Patriots had early success against Mahomes, keeping him out of the end zone in the first half.

Sony Michel had touchdown runs of 4 and 1 yards while Brady hit Julian Edelman for a 17-yard TD pass for another score to give the Patriots their edge at halftime. But just when you thought the hype around Mahomes might be overrated, he offered a reminder of what all the fuss is about. On the Chiefs’ third play of the third quarter, Mahomes floated to his right before firing a 67-yard touchdown pass to Kareem Hunt that got Kansas City back in the game trailing 24-16.

After a swap of field goals made it 27-19, the Chiefs had a chance to tighten the game after defensive lineman Allen Bailey recovered a fumble at the Patriots’ 29 when Brady lost the ball while being sacked by Chiefs linebacker Breeland Speaks. Four plays later, Mahomes zipped a pass to Hill for a 14-yard touchdown that made it 27-26 Pats heading into what proved to be thrilling fourth quarter.

Gostkowski made a 39-yard field goal to put the home team up 30-26 before Chiefs rookie Tremon Smith returned the ensuing kickoff 97 yards to the Patriots 3 yard-line. Three plays later, Mahomes tossed a 1-yard touchdown pass to Hill.

Suddenly, the Chiefs had the lead 33-30 and it was up to Brady, who answered with 4-yard scramble of his own to the end zone to put the Patriots up 37-33. A 50-yard field goal by Gostkowski made it 40-33 before Hill went 75 yards on his catch-and-run to tie the game at 40-40.

“We had the final possession and the final opportunity,” Patriots coach Bill Belichick said. “There was a lot of great execution on that drive by a lot of different people.”

Especially Brady. The torch stays in New England.