McCarthy (3-8), who missed nearly two months with right shoulder inflammation and in June suffered a seizure from a 2012 head injury, had lost in each of his four starts since coming off the disabled list.
But he baffled San Diego Monday, yielding just one unearned run. The right-hander allowed five hits, didn't issue a walk and struck out five in the 93-pitch effort.
Martin Prado led the Diamondbacks at the plate with a two-run single and a sacrifice fly while Paul Goldschmidt drove in two runs, raising his National League-best RBI total to 103.
Tyson Ross (3-7) took the loss, surrendering six runs (four earned) on seven hits over six full innings.
Wil Venable went 2-for-4 with a run scored for the Padres, who fell in the first of a three-game series.
Benedict Cumberbatch's dramatic reading of R. Kelly lyrics is just what you need
Gal Gadot cast as Wonder Woman for 'Batman vs. Superman'