The Padres took two of three from Arizona to capture their final home series of the campaign.
It had been a 2-2 game since the fourth inning when Medica opened the 11th by reaching on an infield single off Josh Collmenter (5-5). Jesus Guzman followed with a ground-rule double and Nick Hundley was walked intentionally to load the bases.
Amarista then drove a single to center on a 2-2 pitch.
The win went to Nick Vincent (6-3), who retired all six men he faced while working the 10th and 11th innings. Arizona did not manage a hit in four innings against the San Diego bull pen.
Arizona's runs came on a homer in the fourth by Martin Prado.