Miguel Montero, Stephen Drew and Kelly Johnson each drove in a run for Arizona, which snapped a four-game skid. Hudson settled down after Freddy Sanchez's first-inning homer, allowing just four more hits.
Drew tripled and scored on Johnson's one-out single in the third, giving Arizona a 2-1 lead, and added a run-scoring single of his own in the seventh.
Montero doubled in Chris Young with two out in the second. The catcher also walked and scored on Drew's two-out hit.
Zito yielded just four hits and struck out seven, but lost his eighth consecutive decision. The left-hander has a 5.49 ERA in 11 appearances since his last victory July 16 against the New York Mets.
Hudson (5-1) retired 10 straight before Pablo Sandoval singled with one out in the seventh. The Giants went on to put runners on first and third in that inning but Hudson got pinch-hitter Travis Ishikawa to ground out to end the threat.