The Cardinals trailed 6-3 after seven innings, but scored three times in the eighth to tie it. After John Jay scored on outfielder Chris Young's error, Albert Pujols socked a two-out, two-run homer to forge a 6-6 tie.
The Cards then put runners on first and second with one out in the ninth and Cruz lined a hit into the right-center field gap off Joe Paterson (0-3), scoring Colby Rasmus with the game-winner.
Fernando Salas (5-2) earned the win with a scoreless top of the ninth for St. Louis, which pulled into a first-place tie with Milwaukee atop the National League Central.
Diamondbacks starter Daniel Hudson delivered a two-run single among his two hits. He surrendered two earned runs on eight hits in a five-inning start on the mound.