Hernandez (6-11) stymied the Diamondbacks on five hits, issuing just one walk while striking out six in posting his second victory over three starts.
The right-hander tossed his eighth career complete game and first 2010, when he was known as Fausto Carmona as a member of the Cleveland Indians.
Yunel Escobar smacked a solo homer in the fourth for a 3-0 Rays lead and later added a sacrifice fly as Tampa Bay won for the 26th time in 32 games and maintained a 1/2-game lead over Boston in the American League East.
Ben Zobrist went 3-for-4 with two RBI in the victory.
Arizona's Ian Kennedy (3-8) absorbed the loss, yielding three runs on six hits over five full frames.
Eric Chavez belted a two-run homer for the second-place D-backs, who came into the contest trailing the NL West-leading Los Angeles Dodgers by 2 1/2 games.
2014: The Year in Music [PHOTOS]