Houston overcame a four-run deficit in a game that saw all but one of the runs score on home runs.
Roy Oswalt (3-3) got the win, surviving six innings while giving up four runs on six hits with four walks.
After Milwaukee had grabbed the early lead, Houston cut its deficit to 4-2 on a two-run homer by Hunter Pence in the fifth.
Berkman and Lee followed with homers to drive Villanueva from the game. Pence added his second homer of the night in the eighth, a solo shot off David Riske.
Jose Valverde struck out two of the three men he faced in the ninth to record his sixth save.