PHOENIX -- With his slumping team down three runs in the sixth inning Wednesday, Arizona manager Bob Melvin started making notes for a postgame pep talk.
"It didn't look good early on," Melvin said. "As a matter of fact, I was drawing up a little speech for after the game."
The Diamondbacks spared him the trouble, rallying for a 4-3 victory on Adam Dunn's winning double in the ninth.
The Diamondbacks won for only the third time in 10 games.
Arizona won in its last at-bat for the third time this season. But this victory seemed bigger because the Diamondbacks hope it will provide momentum heading into a pivotal three-game series beginning Friday night in Los Angeles.
"We've done it before, but it's difficult to do this time of year," said Conor Jackson, who singled in the tying run.
For the second time in three games, Arizona rallied against the Cardinals' tattered bullpen, whose 29 losses are most in the majors.
The winning rally began when streaking Stephen Drew, who went 12-for-26 on the six-game homestand, tripled to lead off the ninth against Chris Perez (2-2).
One out later, Jackson singled through the drawn-in infield to tie it and give Perez his second blown save in eight chances.
Dunn followed with a shot to the right-field corner to score Jackson ahead of the throw. Dunn said he went to the plate looking for a fastball, and Perez delivered it.
"The last one, to Dunn, was probably the worst pitch of the time," Perez said. "It was right over the middle. He put a good swing on it. He's a good hitter."
After sliding across the plate, Jackson bounced up and dashed out to second base, where Dunn was being mobbed by his teammates.
"I expected a little more rough-house," Dunn said. "That was exciting, man."
St. Louis manager Tony LaRussa didn't fault Perez.
"Good hitting against him," LaRussa said. "Sometimes you've got to give the other side credit."
Chad Qualls (4-8) pitched the ninth to earn the victory.
It was a crushing loss for St. Louis, which also blew an early four-run lead in an 8-6 loss in the series opener. The Cardinals won the middle game of the series.
St. Louis went 1-for-10 with runners in scoring position Wednesday, and 3-for-21 in the series.
The Cardinals wrapped up a 1-5 road trip and missed a chance to shave a game off Milwaukee's lead in the NL wild card race. The Cardinals trail the Brewers by 5 1/2 games.
"It's been a tough road trip for us," Perez said. "We had a chance to maybe salvage a little bit with a win today and pick up a game on Milwaukee, but it just didn't happen for us."
The Diamondbacks mustered nothing against Cardinals starter Kyle Lohse, who threw six shutout innings but was denied his first victory since Aug. 1.
Arizona trailed 3-0 in the seventh when pinch-hitter Augie Ojeda led off with a double against reliever Kyle McClellan. One out and two walks later, Ojeda scored on Jackson's fielder's choice grounder to cut St. Louis' lead to 3-1.
Ron Villone came on and threw a wild pitch, allowing Miguel Montero to score to slice the deficit to 3-2.
St. Louis took a 2-0 lead in the third when Cesar Izturis bunted for a single and Troy Glaus followed by hitting an 0-1 delivery from Doug Davis into the left-field seats -- the 300th homer of Glaus' career.
In the sixth, Felipe Lopez reached on an infield single and took second on third baseman Mark Reynolds' throwing error, his 27th error. Lohse followed with a double down the right-field line to give the Cardinals a 3-0 lead.
At that point, Melvin started thinking about giving his slumping team a speech after the game. He chuckled when asked what he planned to say.
"I've got it written down on my lineup card," Melvin said. "I'll save it."
Connect with the Southeast Missourian Newsroom:
For corrections to this story or other insights for the editor, click here. To submit a letter to the editor, click here. To learn about the Southeast Missourian’s AI Policy, click here.