The Grizzlies erased an 18-point deficit shortly before halftime, then polished off the comeback with a wild finish.
Memphis went ahead with 14.3 seconds left when Shane Battier caught a blocked shot under the basket and flicked in a reverse layup. Then Dallas -- which had won eight straight and 19 of 19 -- went back ahead when Dirk Nowitzki made a jumper over Battier from the foul line with 3.1 seconds left.
The Grizzlies beat the Mavericks for the third time this season, winning the season series against their conference rival for the first time in franchise history.
For Dallas, it's a bad way to start a stretch of four games in five days in three cities.
Randolph scored 27 points, Mike Conley had 17 points and 10 assists and Marc Gasol had 16 points and 10 rebounds. Battier had 11 points and 11 rebounds.
The Grizzlies had only 38 points at halftime, then scored 41 in the third quarter alone. They went from being down by 17 at halftime to leading by one going into the final period.
This was only Dallas' second loss since Jan. 22, and both have been by one point at the buzzer.
Jason Terry scored 26 points for the Mavericks and Nowitzki had 23. Roddy Beaubois scored a season-high 15, with 12 coming in the opening minutes; he didn't even play the fourth quarter. Shawn Marion had 10 points and 12 rebounds.
Brendan Haywood, starting in place of injured center Tyson Chandler, had a season-high six blocks and eight rebounds.
The Mavericks notched a couple of impressive milestones, upping their NBA record for consecutive games with a 3-pointer to an even 1,000 and seeing Jason Kidd take over No. 3 on the NBA's career steals list, breaking a tie with Gary Payton. He received a standing ovation when the feat was announced during a timeout.
Memphis scored the game's first basket, then gave up the milestone 3-pointer and was playing from behind the rest of the half. Dallas seemed to do what it wanted, when it wanted on both ends of the court.
Randolph had only six points and two rebounds at halftime, then seemed to remember that he always has big games against Dallas. He started taking over in the third quarter, with 12 points and six rebounds in the period.
The 41 points by the Grizzlies in the third was their second-most in a quarter all season, the most against Dallas in any quarter this season.