Wallace hit the shot, giving the Pistons a five-point lead, and the game appeared over when Wade was called for a technical foul for throwing the ball into the stands.
Tayshaun Prince, though, missed the free throw and Wade hit a 3-pointer to make it 92-90 with 18 seconds left. Richard Hamilton, an 87-percent shooter from the line, then missed two free throws and Wade grabbed the rebound.
After a timeout, Wade missed a wild baseline jumper, but Arron Afflalo gave the Heat one last chance by only splitting his free throws.
Prince tried to foul Wade, but the officials didn't make a call, and Prince stopped to argue as Wade dribbled down the floor to launch his futile attempt at a tying shot.
"I was just thinking 'Please don't go in,'" Iverson said. "That was a hard win, but we did what we needed to do."
Until the wild finish, Pistons point guard Rodney Stuckey appeared to be the story of the game. He hit two jumpers in the last 90 seconds to put Detroit ahead -- the second one an off-balance bank shot over Wade as the shot clock expired.
"I didn't have much choice, because there wasn't any time left," Stuckey said.
Wade acknowledged to being stunned when Stuckey's shot went in.
"Oh man, that was some luck," he said. "There's no way, but it went in for him. Two teams fighting it out, and it came down to him hitting that amazing shot."
Stuckey and Wallace had 18 points each for Detroit, while Antonio McDyess added a season-high 17 rebounds.
Wade led Miami with 29 points and 13 assists.
Detroit led 45-42 at the half, despite not getting a steal or a blocked shot in the first two quarters. The Pistons also forced just two turnovers, but outshot the Heat 52 percent to 36 percent.
The Pistons started the third with a 14-4 run, expanding their margin to 13, but couldn't put the Heat away. Wade's 3-pointer pulled Miami to 62-60 late in the period, only to have Prince answer with two triples of his own.
That let Detroit take a 70-62 lead into the fourth, but Beasley's fast-break dunk tied the game at 76 with 7:35 left.
"There were a couple points where the game could have gotten away from us, but we kept on coming," Miami coach Erik Spoelstra said. "We had a chance to win, but Stuckey hit one heck of a shot."
A crowd of 21,720 -- 356 under capacity -- attended the game, ending the Pistons' franchise-record sellout streak at 259 games. Hamilton and Prince are the only Pistons left from the beginning of the streak, which started a month before the team traded for Wallace. ... Miami's Shawn Marion left late in the first quarter after a collision with Allen Iverson, but returned before halftime. ... Pistons reserve Walter Herrmann missed the game after his wife gave birth earlier in the day.