With the score tied 1-1 in the bottom of the ninth inning, Aramis Ramirez drew a leadoff walk from Patrick Corbin (2-4) and Gomez came in as a pinch-runner.
One out later, Gomez attempted to steal second and catcher Miguel Montero's throw was low, going into center field. Gomez got up and headed for third, sliding into the bag as outfielder Gerardo Parra's throw hit him in the back.
The ball bounded past third baseman Willie Bloomquist and into foul territory, allowing Gomez to trot home with the game-winning run.
The bizarre run made a winner of John Axford (2-5), who tossed a scoreless top of the ninth as the Brewers claimed the rubber match of their three-game set at Miller Park.
The D-backs tied it up in the eighth on Jason Kubel's solo homer.
Josh Collmenter yielded one run on three hits over six full frames for Arizona.
2014: The Year in Music [PHOTOS]