"We put ourselves in the situation where any win can be big for us," Gay told the Grizzlies' website.
Zach Randolph had 21 points off the bench and Gay added 15 as Memphis snapped a five-game losing streak.
"We've got to build on this. (Miami) is one of the best teams in the East," Randolph said. "We should build on this and know we can beat anybody as long as we play defense."
The Grizzlies will finish their current homestand against Golden State on Friday.
Detroit dropped the opener of a brief two-game road trip in Dallas on Tuesday when Dirk Nowitzki led the Mavericks with a season-high 42 points and pulled down 12 rebounds, as Dallas edged the Pistons, 88-84.
Richard Hamilton ended the game with only five points on 1-of-7 from the field in defeat.
"Our guys battled so hard," said Pistons head coach John Kuester. "We were making some great decisions with the basketball."
Memphis has dropped five straight to the Pistons on their home floor and is just 1-8 at home against Detroit since moving from Vancouver, a 72-68 triumph back on Dec. 11, 2004.