Financial terms of the deal were not disclosed.
News of the signing came a day after the Heat learned they would be without Miller until January after he had surgery to repair a torn ligament and fracture in his right thumb.
Stackhouse, who was taken with the third overall pick by the Philadelphia 76ers in the 1995 NBA Draft, is a two-time All-Star.
He has averaged 18 points per game over 15 seasons spent with five different teams. Last season, he averaged 8.5 points in 42 games with the Milwaukee Bucks.
Miami open their regular season against the Boston Celtics on Tuesday.
(Reporting by Frank Pingue in Toronto)