In a game of dueling masterpieces from Nikola Jokic and Kyrie Irving, neither of them dealt the decisive blow.

Michael Porter Jr. attacked a close-out and buried a go-ahead 14-footer with 6.5 seconds left, and the Nuggets won a 122-120 thriller over the Mavericks to complete a perfect five-game homestand on Sunday.

Jokic went for 37 points, 18 rebounds and 15 assists — only the 11th 35-15-15 game in NBA regular-season history and his second. Irving scored 43 points on 17-of-22 shooting from the field. The only two 3-pointers he missed were his last two. Peyton Watson contested one of them to give Denver (7-3) a chance to break the tie. And Christian Braun contested the other as time expired.

Jokic tipped in his own miss with 49 seconds left to tie the game and set up for Denver’s fifth win that has come down to the last possession of regulation.

Watson continued to thrive in Aaron Gordon’s place among the starters, making all four 3-point attempts en route to 16 points. Porter scored 13 of his 17 points in the first quarter. Jamal Murray scored 13 of his 18 in the second half. Julian Strawther added 12 off the bench.

For a moment, it seemed the Nuggets’ healthy balance wouldn’t be enough to outshine one supernova of a game from Irving. He lit up Denver’s second unit for three quick long-range jumpers in the fourth quarter, flipping the Mavericks’ three-point deficit to a three-point lead. Nobody could keep him from getting to his spots, not Braun and not the supporting cast Denver tried to swarm Irving with.

But Luka Doncic was held to 24 points on 9-of-19 shooting, and new Maverick Klay Thompson only contributed 10 points.

The Nuggets more or less survived a stretch of more than six minutes with Jokic on the bench and Doncic on the floor at the beginning of the second quarter. It was rough at first. Russell Westbrook committed two turnovers leading to easy buckets, and Zeke Nnaji missed a pair of free throws. But the window was extended by a lack of dead balls after Jokic went to the scorer’s table, and Denver stole back five consecutive points from Watson and Strawther.

Dallas won the minutes 19-14, but the Nuggets had the lead as Jokic and Doncic traded places. They just couldn’t protect it for the remainder of the half. Irving started getting around Braun and making tough shots. Murray made a handful of sloppy decisions, and he didn’t deliver the usual shot-making to compensate for them. At the half, Denver was outscoring Dallas by 15 from the perimeter and getting outscored by 16 in the paint.

Zeke Nnaji logged 10 minutes in his fourth consecutive game at the backup five in Malone’s rotation, after Dario Saric started the season in that role.

The Nuggets have four days off before they visit New Orleans on Friday to start a three-game road trip. It will be their first of four group stage games in the in-season tournament, now known as the Emirates NBA Cup.