Stephen Curry had 25 points and Klay Thompson had 21 for the Warriors, shooting a combined 8 for 10 from 3-point range. David Lee had 15 points as Golden State lost for the first time in four preseason games.
The Nuggets led 94-92 when Brewer six straight points. He was fouled while shooting a 3-pointer and hit all three free throws and then made a 3 to give Denver a 100-92 lead.
Golden State responded with six in a row and had two chances to tie but Jeremy Tyler was called for a charge and then Kosta Koufas blocked his layup attempt with 49 seconds remaining.
Koufas, who had 13 rebounds, sealed the win with two putbacks that gave Denver a 104-98 lead.
Denver led by nine early in the third quarter when the Warriors made a push. Curry hit two 3s and rookie Harrison Barnes had one to cut the deficit to 65-64.
Curry gave the Warriors an 86-84 lead -- their first lead of the game -- with his fourth 3 with 1:02 left in the third quarter. Denver scored the first six points of the fourth quarter to take the lead for good.
The Nuggets never trailed in the first half and were tied only once, at 19-all midway through the first quarter. They scored the next eight points and led by as many as 12.
The Warriors rallied late in the second quarter to cut the lead to 56-53 at halftime. Thompson had 13 points and Curry scored 12 at the break.
Gallinari led the Nuggets with 12 points at intermission.
Nuggets guard Andre Iguodala, acquired from Philadelphia in a four-team trade in August that sent Dwight Howard to the Lakers and Andrew Bynum to the 76ers, had 10 points and a game-high seven assists in his first game in Denver.