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.
Barry Zito (8-12) was almost as good as Hudson, working six solid innings, but it wasn't enough for San Francisco, which trailed NL West-leading San Diego by a game entering play Wednesday.
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.
NOTES: Diamondbacks interim manager Kirk Gibson said he would like to be back as the permanent manager of the club next season. "I certainly feel that I can take the organization where they need to go," he said. ... Arizona 3B Mark Reynolds returned to the starting lineup for the first time since Sunday, when he aggravated a hand injury and had to leave the game. Reynolds entered Tuesday's game as a pinch hitter.