PHOENIX -- Arizona manager Bob Melvin walked to the mound with two outs in the ninth inning Sunday and didn't say a word to his closer.
"I didn't tell him anything," Melvin said of right-hander Jose Valverde. "He didn't want to see me. He's a pretty superstitious guy."
Tony Clark's two-run double capped a four-run rally in the seventh inning that put Arizona up 6-4. Justin Upton tied the score with his first homer since Aug. 7 and Chris Young also connected for the Diamondbacks, who moved three games ahead of San Diego in the NL West.
"We were fortunate enough to win but if we pat ourselves on the back it defeats the purpose," Clark said. "There's still a lot of baseball to be played."
The Cardinals fell three behind first-place Milwaukee in the NL Central.
"Bad results, but if we go about it that way we'll be fine," said Cardinals manager Tony La Russa, whose club has lost four of five. "I've got no complaints about the way we went at it all three days."
Yusmeiro Petit (3-4) pitched two innings of one-hit ball for the win. Valverde came on in the ninth for his major league-leading 45th save in 52 chances.
Pinch-hitter David Eckstein drew a walk that made it 6-5, but Valverde quickly got ahead of Molina and retired him on an easy fly to right.
"If you can't handle pressure you're not going to be a closer," Melvin said.
Four Diamondbacks relievers combined for five innings of two-hit relief.
"They've got some great arms here," said right-hander Bob Wickman, who made his Arizona debut in the fifth inning. "It's unbelievable."
After Upton settled into the batters' box to face Wells, La Russa pulled the right-hander in favor of Ryan Franklin (4-3). But Upton hit Franklin's third pitch 411 feet into the left-field stands to tie the game at 4-all.
"It's been different people every time," Young said. "Today was Justin's time."
The Cardinals did all their damage during a six-batter span in the third inning against Doug Davis, scoring four runs on five hits.
Upton was shaken up when he ran into the fence chasing Cairo's triple. He appeared to hurt his left knee when it slammed into one of the supports, tearing his uniform pants, but remained in the game.
"There was a guy on so I was going to do whatever I could do to get it," Upton said. "It stung a lot at first but I walked it off and the pain subsided."
St. Louis' Brad Thompson allowed two runs and four hits in two innings, his shortest start of the season.
Mark Reynolds hit a one-out single off Thompson in the second and Young followed with his 29th homer into Arizona's left-field bullpen.
"I knew obviously there was a decent chance," Wells said of his outing from the bullpen. "Somebody needs to pitch those innings. It's not like I had an overwhelming sense that I was going to throw but it's a situation where you know you need to be ready earlier rather than later."
- Wickman walked one and striking out one in a scoreless inning in his first appearance since Aug. 23 with Atlanta.
- Molina, who was scratched from the lineup Saturday with concussion-like symptoms, started Sunday on the bench as well.