Brooklyn almost held the Heat scoreless for the entire second extra period with Miami's only points in the stanza coming from Ray Allen with 16 seconds remaining.
The Nets continued to climb out of an early-season hole by winning their fifth straight game. Miami has lost the opening two contests of a six-game road trip after winning five out of six.
Miami's Dwyane Wade did not play due to knee soreness and LeBron James fouled out of a game for the first time in six seasons. James scored 36 points before committing his sixth foul with 36 seconds left in the first overtime. Miami scored just two more points the rest of the game.
The Heat overcame a 12-point deficit at the start of the fourth quarter to force overtime. Brooklyn's Paul Pierce had a chance to win it at the end of both regulation and the first extra period, but he missed a 3-point try on both occasions.
Livingston and Johnson scored the first two field goals of the second overtime and Pierce then hit a 3-pointer to boost the lead to seven.
Johnson scored 32 points, Pierce had 23 and Livingston had 19 in a career-high 51 minutes. Livingston, plagued by knee problems, is playing with his eighth NBA team in nine seasons and is now Brooklyn's starting point guard.