The Nets ended Golden State's 10-game winning streak, handing the Warriors their first setback since a two-point loss to San Antonio Dec. 19.
Golden State's last six wins had come on the road and this was the finale of a seven-game trip.
Brooklyn fell behind by 10 points after one quarter, rallied for a seven-point halftime advantage and made the key plays down the stretch to win its fourth in a row.
Stephen Curry made three free throws to bring the Nets within two and Garnett was immediately fouled after the inbounds pass with nine seconds remaining.
Garnett hit both free throws, but Curry quickly hit a jumper that again lifted the Warriors within two. Johnson then made two more from the foul line with five seconds to wrap up the victory.
Johnson scored 27 points to lead Brooklyn and Andray Blatche added 18 points off the bench. Both Garnett and Shaun Livingston had 13 points.
Curry made only 11-of-25 shots from the field, but wound up with 34 points. David Lee added 20 points and seven rebounds for the Warriors.