PHOENIX -- Running the bases in the fifth inning, Kyle Lohse felt a twinge in his hamstring and hoped to avoid falling down.
David Freese had three hits as St. Louis won its fourth in a row. Arizona has lost five straight at home and seven of eight overall.
Lohse's adventure began after he singled with one out and headed for third on Rafael Furcal's single.
Lohse said he felt "general soreness" in his right hamstring. He awkwardly lunged for the bag as Gerardo Parra's throw came in because "if I had slid, it would have been a flop headfirst."
"I was just hoping I wasn't going to be laying there between second and third," he said.
The right-hander said his warm-up throws before the fifth were the litmus test.
"I just wanted to make sure that I could get through it," Lohse said.
Staying in for an extra inning helped the Cardinals' first lead.
Carpenter came up with the score 1-all in the sixth after David Freese led off with a walk and Tony Cruz hit a two-out single. As Carpenter was announced, Arizona's bullpen phone rang and pitching coach Charles Nagy sprinted to the mound.
Carpenter doubled home Freese and Cruz.
"What worked out was Carp put together a nice at-bat against a left-hander and got a huge hit to change the game," Cardinals manager Mike Matheny said. "It worked out all right."
Lohse (5-1) allowed one run on seven hits before giving way to the bullpen.
Carpenter was happy to take advantage of that opportunity.
"I've always thought of myself as a student of the game," he said. "I just watch and put myself into those positions mentally before they happen."
The Cardinals extended their lead with a two-out surge in the ninth against J.J. Putz. Furcal and Carlos Beltran singled, Matt Holliday hit an RBI double off the center-field wall, and Craig then hit his third home run.
Putz, making his first appearance in five days, allowed four runs on five hits while getting two outs.
The Diamondbacks loaded the bases on three straight singles leading off the ninth against Mitchell Boggs, but Jason Motte came on and retired the side on a strikeout and a double play for his sixth save.
"I like watching him pitch," Matheny said of his closer. "I like getting him saves anytime we can."
The Diamondbacks' skid at home continued.
"We just got out-executed the whole series," Gibson said. "They scored 23 runs; we scored nine. They outpitched us. They outdefended us. They swung the bats better than we did. And we are happy to see them go."
Three consecutive singles, the last on a looping hit to center by Miley, gave the Diamondbacks a 1-0 lead in the second.
Miley pitched 5 2/3 innings, allowing three runs on 10 hits with two walks. He lost for the first time since Sept. 16 at San Diego, a span of five starts and eight appearances.
"Late in the game I didn't make pitches when I needed to," he said.
Lohse has thrown exactly five innings in each of his past two starts. ... The Diamondbacks had been outscored 20-1 in the first four innings of their previous four games before Miley kept the Cardinals scoreless over the first four. ... Miley's single extended his hitting streak to five games, the longest by an Arizona pitcher since Barry Enright's five-game streak in 2010. ... Both teams have off days Thursday. LHP Jamie Garcia will go for his 30th career win against Mike Minor and the Braves in St. Louis on Friday. Rookie LHP Patrick Corbin will open a three-game series against San Francisco at home for Arizona, also Friday.