The Cleveland Cavaliers, meanwhile, pulled off an impressive comeback victory to take a 3-2 lead over the Toronto Raptors in the first round of the play-offs.
Cunningham scored a Pistons play-off record 45 points to drag his side to a 116-109 victory on a must-win night, steering Detroit back to a 3-2 deficit in the best-of-seven series.
The Pistons' star man, having recently returned from a collapsed lung, played nearly 44 minutes as Detroit avoided a stunning first-round ouster at the hands of eighth-seeded Orlando.
"We dug ourselves a big hole, it's going to be a tough one to climb out of, but we handled business tonight," said Cunningham.
"We're at our best when our backs are against the wall," he added.
Having dominated the Eastern Conference during the regular season, Detroit has faltered badly at the start of the post-season.
Needing to win three in a row to escape the first round, the Pistons came out of the blocks fast in front of a home crowd on Wednesday.
Playing with a high energy bordering on desperation, Detroit owned the glass with 17 rebounds in the first quarter, building a 12-point lead.
Cunningham exploded into the game with 20 points in the second quarter alone.
But the gap closed to six points by half-time, and Orlando missed two go-ahead three-pointer attempts soon after the break.
The Pistons took advantage and powered well clear. Orlando refused to quit, mounting a late charge including a pair of Paolo Banchero three-pointers that narrowed the lead back to three points.
But a Cunningham triple with barely 30 seconds remaining sealed the win. Banchero top-scored for Orlando with 45 points.
The Magic will have another chance to finish a surprise series win on Friday back in Orlando. A possible decider would take place in Detroit on Sunday.
LeBron's 25 not enough
Jabari Smith Jr's 22 points helped the Houston Rockets grind out a gritty 99-93 win to bring their series with the Los Angeles Lakers back to 3-2.
The Lakers had led 3-0, but now face a tricky trip to Texas for game six.
The return of key offensive contributor Austin Reaves after nine games out with an oblique injury had boosted the Lakers, who got off to a bright first quarter on Wednesday.
But the Rockets - who were again without star forward Kevin Durant with an ankle issue - shot ahead, building a 13-point advantage midway through the final quarter.
A LeBron James driving layup reduced the deficit to single digits with five minutes remaining, pumping up the home crowd.
But it was not to be for the Lakers. Another loss in Houston on Friday would put the Lakers at risk of becoming the first team in history to blow a 3-0 lead in a play-off series.
Veteran 41-year-old superstar James top-scored on the night with 25 points, continuing his remarkable post-season form, but failed to score any of his three-pointer efforts.
"We just couldn't make shots," said Lakers coach JJ Redick.
"Missed some layups, certainly had some good looks for three that didn't go down. But we'll take a look at the whole process."
Cleveland secured a fifth straight win for the home team in their series against Toronto to take a 3-2 lead.
Having twice trailed by 12 points, Cleveland powered back in the second half with a much stronger defensive performance to win 125-120.
Evan Mobley led the rally with 10 points in the third quarter, while Dennis Schroder added 19 off the bench.
The result means all four Eastern Conference first-round play-off series now stand at 3-2.
