PHOENIX -- Facing division rival Los Angeles for the fourth time in two months, Diamondbacks starter Trevor Cahill reached deep into his bag of tricks.
"I felt confident I could throw all four pitches anytime in the count," said Cahill, who has won his past four starts against Los Angeles. "If you only have two pitches working and they know it and I know it, you end up trying to throw too fine a pitch."
Justin Upton and Gerardo Parra hit back-to-back RBI singles to support Cahill's seven strong innings.
|More on Dodgers-Diamondbacks|
|More MLB coverage|
The Dodgers, who have lost six of seven, squandered a chance to pull even with St. Louis in the race for the second NL wild-card spot. The Cardinals lost 3-2 to San Diego earlier Wednesday.
The defeat left Los Angeles a game behind St. Louis. The teams will begin a four-game series Thursday at Dodger Stadium.
"I'm sure people are getting tired of hearing me say it, but we have to turn the page," Dodgers manager Don Mattingly said. "St. Louis and ourselves, we have let a lot of people back in the race -- but it's still in our hands. No matter how bad it has looked and no matter where it has been, it's still right there for us."
Arizona (71-72) moved within four games of the Cardinals.
"It's getting better," Diamondbacks manager Kirk Gibson said. "We need to keep running in the same direction we're going now, but it's getting interesting."
Cahill (11-11) scattered four hits, struck out seven and did not walk a batter for the second time this season. He also did not issue a free pass June 20 against Seattle.
"He kept it together," Gibson said. "He limited the damage and that was big."
Los Angeles took a 2-0 lead in the first when Shane Victorino singled, Cahill hit Matt Kemp with a pitch and Adrian Gonzalez hit a two-run double to right-center.
After that, Luis Cruz's two singles represented all the offense for the Dodgers over the final eight innings.
"It feels good that you're able to score two early," Mattingly said. "But that feeling goes away as you're not able to add on. As the game gets later you've given the momentum back."
Pitching with a 2-1 lead, Dodgers starter Aaron Harang issued consecutive two-out walks in the sixth. Upton followed with a single to tie the game at 2 and end Harang's night.
Left-hander Randy Choate came on to face the left-handed hitting Parra, who lined a single to right that gave the Diamondbacks a 3-2 lead.
"You get two guys who are up there that can change a game real quick, so you're not trying to lay a cookie in there," Harang said. "You're trying to give them something to swing at that they're either going to hit softly or hit on the ground somewhere. Then I end up walking those guys."
Harang (9-9) allowed four hits in 5 2/3 innings but walked four.
David Hernandez pitched the ninth for his second save in two nights, retiring Kemp, Gonzalez and Hanley Ramirez in order.
"As closer, that's who you want to face," Hernandez said. "They're not all going to be three-run saves."
Gonzalez, punched out on a called third strike for his third strikeout of the game, thought it was ball four.
Los Angeles, which dropped seven games behind first-place San Francisco in the NL West, is batting .184 in its last five games with one homer and seven runs.
The Diamondbacks have won 10 of the past 12 meetings between the clubs. Arizona starters are 9-0 with a 1.75 ERA in their past 12 games against the Dodgers.
"Winning one-run games against division rivals, sometimes those are better than blowouts," Cahill said.
The Diamondbacks cut Los Angeles' lead in half in the second when Paul Goldschmidt singled, stole second, went to third on a wild pitch and scored on a sacrifice fly by Upton.
Hernandez last recorded back-to-back saves on July 7-8, 2011. ... Arizona has won consecutive one-run games for the first time since opening the season with three straight one-run victories over the Giants. ... Diamondbacks closer J.J. Putz missed his second straight game with stiffness in his back. ... Harang is 3-8 with a 3.19 ERA in 17 career appearances and 16 starts against Arizona. ... What better way to reduce some pennant-race tension than phantom infield practice? Before the game, the Dodgers pantomimed their way through their infield warmup, with the fielders scooping imaginary grounders and catchers stumbling in foul territory under invisible, sky-high popups. ... Dodgers RHP Josh Beckett (1-2) starts against St. Louis RHP Lance Lynn (14-7) on Thursday. The Diamondbacks have the day off before rookie LHP Tyler Skaggs (1-1) faces RHP Matt Cain (13-5) to begin a three-game series against San Francisco.