Arizona has lost seven of nine, dropping its NL West lead to 1½ games over the second-place Los Angeles Dodgers, who beat San Diego 8-4.
"Our focus has to continue to be on us and we just have to play better," Diamondbacks manager Bob Melvin said.
St. Louis is 5½ back of Milwaukee in the wild-card race.
"There's no sports writer, no fan that's telling me we're out of this thing," Wainwright said. "Until the last game of the season I'm battling like we're going to be ready for the playoffs."
On Monday, the Diamondbacks rallied from four runs down to win 8-6. This time the deficit reached 8-0, and there was no big comeback.
Wainwright (8-3), in his third start since returning from the disabled list, shut out the Diamondbacks through five before giving up a run in the sixth. He struck out seven and walked two, yielding three hits in 5 1/3 innings.
He was bothered by back spasms in the hotel before the game, and needed some therapy from trainers before taking the mound. He said his back stiffened again when he ran the bases in the top of the fifth, leading to his exit soon thereafter.
Wainwright said making his start was never a question, though.
"I do this several times a year so I knew I could get through it," he said. "It kind of works in my favor because there is no way I can pop out of my pitches too early. I made sure I stayed through my delivery the whole time."
Wainwright returned 10 days ago after being sidelined since June 8 with a right middle finger sprain. He is 2-0 in three starts since.
"I don't know how we stayed in it without him, to be honest with you," manager Tony La Russa said.
Five Cardinals relievers, including Chris Carpenter, finished the seven-hitter.
Yusmeiro Petit (3-4) gave up five runs and four hits in 4 2/3 innings, the fourth Arizona starting pitcher in a row to have a rough outing.
"Sometimes it's contagious," Melvin said. "The next guy tries doubly hard to give you a good, solid outing. It certainly isn't characteristic of our staff, our rotation."
Glaus, 2-for-13 through four games of a six-game road trip, was moved up to the No. 2 spot in the batting order, just ahead of Albert Pujols, to try to get the big slugger going.
"I've done it a few times in the past," Glaus said. "I enjoy it. I mean, it's always nice when you've got Albert hitting behind you."
It worked. Glaus singled in the first, then lined Petit's 2-1 pitch into the left-field stands. His 22nd home run put St. Louis up 2-0 in the third.
The Cardinals added three in the fourth on consecutive homers by Molina and Lopez.
With no outs in the sixth, the Diamondbacks intentionally walked Lopez to get to Wainwright, who lined a double down the left-field line on the first pitch to make it 7-0.
After going 5-for-5 and hitting for the cycle on Monday, Arizona's Stephen Drew went 0-for-4.
- Arizona OF Justin Upton was a late scratch from the lineup because of a headache. He was hit behind the ear Monday on a pickoff attempt by the Cardinals' Brad Thompson.
- The Diamondbacks have allowed 28 runs in their last four games, all at home.
- Carpenter came on in the seventh for St. Louis, his first relief appearance since Oct. 1, 2000, and threw a scoreless inning despite giving up two hits. He had been out since Aug. 10 with a right shoulder sprain.