Hill put an end to the wild contest with a one-out knock liner to left off Dale Thayer (2-4) for Arizona's 11th walk-off win of the season.
The win inched Arizona to within 8 1/2 games of the Dodgers in the NL West and five games behind Cincinnati in the race for the second wild card berth.
Hill also had two walks in the contest, which was sent into extra innings after San Diego rallied for six runs in the eighth and ninth innings.
Heath Bell (5-2) picked up the win in relief. Gerardo Para had five RBI for the Diamondbacks on two hits, including a solo home run in the second inning off San Diego starter Ian Kennedy. Martin Prado drove in three runs.
Jedd Gyorko and Nick Hundley had two RBI apiece for the Padres.