Arizona had taken a 3-2 lead in the top of the sixth on a bases-loaded walk by Brandon Allen, but San Diego answered with a two-out rally in the bottom of the inning.
Hudson was pushed to second when Kyle Blanks was hit by a pitch and came around when Martinez singled to left.
The rally was charged to Daniel Hudson (10-7), who allowed seven hits in addition to the four runs over six innings. He walked two and struck out six.
Luke Gregerson (3-3) got the win with an appearance of two-thirds of an inning. Heath Bell earned his 30th save with a one-hit ninth inning.
Allen hit a two-run home run -- his third this year -- in the Arizona second and San Diego got a solo home run from Guzman -- his fourth of the season -- in the bottom of the inning. The Padres tied the score in the fourth on an RBI single by Guzman.
2014: The Year in Music [PHOTOS]