DALLAS — On the day the New York Knicks guaranteed his contract for the rest of the season, Jarrett Jack hit the big shot to deliver them a victory.

Jack's floater in the lane with 31.2 seconds to play snapped a tie and the Knicks beat the Dallas Mavericks 100-96 on Sunday night.

Kristaps Porzingis scored 29 points for New York, which ended a three-game losing streak and sent the Mavericks to their third straight loss — all at home.

Dallas never led in the game, but for the third game in a row, the Mavericks made a late rally from a double-digit deficit — and fell short just as they had against Golden State and Chicago.

"It's really the same old story," Mavericks coach Rick Carlisle said. "It's an early hole, it's a late rally, and then come up short. Bottom line is we've got to be better early in games."

Harrison Barnes scored 25 points and Devin Harris had nine of his 11 in the fourth quarter for Dallas on the night the team honored long-time point guard Derek Harper by retiring his jersey.

The Mavericks trailed 90-77 with 4:48 left, but went on a 15-2 run over the next 2:20 to tie the score at 92. Harris started and ended the run with 3-pointers.

"We did what we were supposed to do all game, turned up the pressure and intensity," Mavericks guard Wesley Matthews said. "It was just a little too late."

After Porzingis made two free throws and Barnes hit a short jumper, Jack used Porzingis' screen to penetrate into the lane and drop in a floater.

"I was just trying to be aggressive," Jack said. "They had done a good job of mucking the game up, denying a lot of our actions, not allowing us to get the ball in the place that we were trying to get it to. (Porzingis) set a good screen. I saw I had an opening and I just tried to knock the shot down."

J.J. Barea missed a long 3 that would have given Dallas the lead, and Courtney Lee hit four free throws in the final 16.6 seconds to seal it.

Up 56-52 at halftime, New York built its lead to 73-63 midway through the third quarter before the Mavericks closed the quarter on an 8-2 run.

But after Harris' three-point play cut the lead to 77-74 with 11:27 to play, Dallas did not score again for five minutes as the Knicks built the lead back to 13.

TIP-INS

Knicks: Lee has made 43 free throws in a row, the second-longest streak in Knicks history. Chris Duhon made 44 in a row in 2008-09.

Mavericks: Matthews had 14 points and four Mavericks scored 11.

HARPER HONORED

The Mavericks retired Harper's No. 12, the third Dallas player to be so honored. Harper's jersey joins those of his former teammates Brad Davis (No. 15) and Rolando Blackman (No. 22) in the rafters. Harper played 12 seasons in a 16-year career with the Mavericks, ranking fourth in the team's history in points and first in assists and steals. Harper also made the NBA Finals with the Knicks in 1994 and is now the analyst on Mavericks' TV broadcasts.

"I kept looking up at Brad and Ro's numbers during the first half of the game and just thinking that I was going to be up there joining those guys. " Harper said after the game. "When reality sets in, this is a big deal because not a lot of people get to have their jersey retired. It's an incredible honor."

BATTLE OF THE ROOKIES

Harper wore No. 11 with the Knicks, and that jersey is now worn by rookie point guard Frank Ntilikina, the eighth pick in the 2017 draft. The Mavericks took Dennis Smith, Jr. with the next pick. Smith won the scoring battle on Sunday, 11 points to seven, and both players had five assists. Ntilikina added seven rebounds and was on the floor for most of the fourth quarter as the Knicks built their double-digit lead.

DOUBLE-DOUBLES

Kyle O'Quinn had 15 points and 11 rebounds, and Enes Kanter added 13 points and 18 boards for the Knicks. Porzingis fell just two rebounds short of a double-double of his own.

UP NEXT

Knicks: Return home to play Chicago on Wednesday.

Mavericks: Host Orlando on Tuesday.