Bam Adebayo sealed the 111-108 win with a pair of free throws with 48.3 seconds remaining.
The Heat were 15 points down in the first half but outscored their opponents 36-25 in the final period.
Miami host game three of the best-of-seven series on Wednesday (Thursday 01:30 BST).
The Heat, who are aiming to become the first eighth-seeded team to win the title, were led by Gabe Vincent (23 points). Adebayo and Jimmy Butler scored 21 apiece in the win.
Nikola Jokic top-scored with 41 points for the Nuggets, but the defeat - their first home loss since 30 March - left coach Michael Malone frustrated.
"Let's talk about effort," said Malone. "I mean, this is the NBA Finals and we're talking about effort. That's a huge concern of mine.
"We had guys out there that were just, whether feeling sorry for themselves for not making shots, or thinking they can just turn it on or off.
"This is not the pre-season. This is not the regular season. This is the NBA Finals. That to me is really, really perplexing, disappointing."
The Heat, who lost the series opener 104-93, started game two strongly and led by 11 with less than five minutes to play in the first quarter but the Nuggets, with their bench players to the fore, battled back to lead 57-51 at the break.
The Heat tied it up at 66-66 midway through the third quarter but were 83-75 down going in the deciding period.
However, the visitors went on a 15-2 scoring run, taking the lead for the first time since the first quarter thanks to a Vincent three-pointer with 10:10 to play and never trailed again.
"During the fourth quarter, our guys love to compete," Heat coach Erik Spoelstra said. "They love to put themselves out there in those moments of truth.
"Fortunately we were able to make a lot of big defensive plays down the stretch, and then we got a lot of contributions, which you're going to need against a team like this."