DENVER -- Randy Foye made a go-ahead 3-pointer in the waning moments and then helped it stand with his last-second defense.
"It was huge," Foye said. "I work extremely hard on my shot, so 5 for 12, 1 for 12, it doesn't matter, just got to continue to shoot the ball with confidence."
Ty Lawson scored 20 points to lead the Nuggets, who won their fifth straight at home while ending Dallas' four-game winning streak. Kenneth Faried had 18 points and 14 rebounds, and Foye finished with 17 points.
Dirk Nowitzki had 27 points but, with Foye contesting it, missed a shot at the end that would have sent the game into overtime.
"When I saw him with the ball, I thought, `I know he's going to hit me and I know he's going to fadeaway," Foye said. "I have no chance to block the shot, so don't let him get comfortable. When he bumped me a little bit, I nudged him back."
Nowitzki's shot ended up hitting off the rim.
"We ran a good play," Nowitzki said. "I thought Vince (Carter) was halfway open, decided not to shoot. Then we ran a little pick and roll and the clock was going down and I had to heave one. It was still a decent look to tie it, but it just didn't go in.
"I've got to be a little better down the stretch. I missed my last two or three shots."
Monta Ellis added 25 points and Carter had 16 for the Mavericks, who were without coach Rick Carlisle for most of the game after he drew two technical fouls in succession and was ejected by referee Tony Brothers with 5:14 remaining in the second quarter.
Carlisle was initially upset that officials didn't send Nowitzki to the free throw line, ruling the Mavericks forward was in the act of passing, not shooting, when he was fouled by Wilson Chandler.
Moments later, Ellis took a hard foul from Foye and was sent to the line, but Carlisle apparently was upset the foul wasn't considered flagrant and let Brothers know it, leading to his ejection.
"I thought the foul was excessive," Carlisle said. "I thought he fouled him and he came down on him extra hard. I'm going to stand up for my players."
Assistant coach Monte Mathis took over on the bench for Carlisle.
The Mavericks trailed by as many as 17 points early in the game and were down 65-53 at the half. But they fought back to 84-78 with 19 seconds remaining in the third quarter on a 3-pointer by Carter, his third 3-pointer in the period.
Carter hit another 3-pointer, pulling Dallas within 86-85 with 10:13 left to play.
Faried answered with a short jumper but Dallas got consecutive baskets from DeJuan Blair and Ellis to go in front 89-88, its first lead since midway through the first quarter.
The game remained tight in the final minutes, with the teams alternately taking the lead. Dallas put together a 6-0 run that included consecutive jumpers by Nowitzki that put the Mavs up 100-98 with 2:02 remaining.
That set the stage for Foye's go-ahead 3-pointer with 1:11 left to play as the Nuggets regained the lead 101-100.
After Nowitzki missed a jumper, Faried rebounded and was fouled by Blair, making one of the two free throws with 14.7 seconds left.
Nowitzki missed a long jumper in the final seconds as the Nuggets hung on.
"We're getting them, that's all that matters, as long we're getting the wins," Faried said. "I'm excited. The team is excited and the coach is excited."
Dallas, a 103-93 winner over Utah the night before, missed a chance to sweep a back-to-back for the first time this season. Denver improved to 49-8 since the start of the 2009-10 season when facing a team playing the second game of a back to back in the Mile High City.
The Nuggets' Andre Miller registered his 7,988th assist in the NBA on an alley-oop pass that Chandler converted into a dunk midway through the second quarter, surpassing Rod Strickland for ninth all time. ... Ellis has scored at least 18 points in each of the Mavericks' first 14 games. ... Chandler has scored 10 or more points in four of his first six games since returning from a hamstring injury that sidelined him for the first two weeks of the season. ... Faried recorded his sixth double double of the season and fifth in his past seven games. ... Dallas has gone 4-6 in its past 10 games in Denver.