Dallas coach Rick Carlisle wasn't second guessing his decision to give Nowitzki the night off as the Mavericks played for the 11th time in 18 days.
"It was just the right thing to do, the right thing for him, for the organization," Carlisle said. "He needed a day to rest."
Carlisle said Nowitzki will return when the Mavericks visit Brooklyn on Friday night. Nowitzki leads Dallas with an average of 21.1 points per game.
Jae Crowder started in place of the 34-year-old Nowitzki, who missed his second game of the season. Nowitzki sat out a Dec. 14 win over Milwaukee due to illness.
Monta Ellis had 21 points while Jose Calderon and Brandan Wright each had 13 for Dallas, but the Mavericks hurt themselves with 21 turnovers, including nine in the fourth quarter. They led by 21 in the first quarter and by five going into the fourth.
"Very frustrating," Mavericks swingman Vince Carter said. "This is a game we should have won, regardless of whether Dirk was on the floor or not."
Jonas Valanciunas had 12 points and 10 rebounds for the Raptors, who overcame a 21-point, first-quarter deficit, the fifth-biggest comeback in franchise history.
Toronto rallied from a 19-point deficit to beat the Mavericks 109-108 in overtime in their last meeting, Dec. 20 in Dallas.
"This is the year of no lead too big, no deficit too great," Carlisle said. "You're seeing big leads disappear all the time.
"We've got to be better with leads because they're hard to get."
Toronto blew a 17-point lead in the third quarter and lost at home to the Lakers on Sunday. They fell behind by 30 at Charlotte on Monday before cutting the deficit to one, but ended up losing again.
With those defeats in mind, DeRozan wasn't about to let this one slip away.
"This loss would have hurt," DeRozan said. "We didn't want to lose three in a row. I was just telling myself just try and do as much as I can to win, try to pull this one off and keep my team in it."
DeRozan connected on 15 of 22 field goal attempts and went 9 for 14 at the free throw line, becoming the seventh player in Raptors history to score 40 points or more. No Toronto player reached the mark more often than Carter, who did it 14 times.
Carter, who spent more than seven seasons with the Raptors, said he was impressed with DeRozan's performance.
"He's a very good player, very athletic," Carter said. "I think he's really learning how to play under control now. When you have athleticism like that sometimes you just go, you just play and let your athleticism take over. He's now slowing down and everything else is developing and it's just making him a tough player.
Toronto guard Kyle Lowry came in averaging more than 18 points per game in January, but struggled in this one as he dealt with flu-like symptoms. Lowry missed his first nine field goal attempts and didn't find the scoresheet until making a pair of free throws at 9:12 of the fourth.
Lowry was fouled again at 5:13 after a Dallas turnover, making one of two to tie it at 80-80 with 5:13 left.
DeRozan converted a three-point play to put Toronto up 85-82 with 3:38 left, but Wright answered with a jump hook.
Amir Johnson hit a 3 on Toronto's next possession, causing Dallas to call timeout. After Wright made one of two from the line, Johnson missed an alley-oop dunk, but was still under the Mavericks basket when Vasquez stole a wayward pass by Ellis. Vasquez fed Johnson for the slam, putting Toronto up 90-85.
Vasquez picked off an errant pass by Calderon on the next possession and DeRozan reached the 40-point plateau with a fast-break dunk, putting the Raptors up 92-85 with 1:48 remaining.
"We couldn't match their intensity in the second half," Calderon said. "Then they made their run and we couldn't keep up with that."
DeRozan's previous career-high was 37, set three times. ... Lowry finished 0 for 10 from the floor and scored three points. ... Toronto announced that F Landry Fields underwent minor surgery Tuesday on his right wrist. Fields will be able to resume basketball-related activities in three weeks. ... Raptors F Tyler Hansbrough (left ankle) missed his 11th straight game. ... Dallas dropped to 11-12 on the road. ... Rapper Drake attended the game.