The Rockies took their first lead of the series on a Brandon Barnes double that scored Matt McBride to make it 1-0 in the second.
Matt Holliday's double scored Jon Jay to tie the game in the third. Peralta followed with a two-run homer to left to give the Cardinals a 3-1 lead.
Peralta's 21st homer extended his club record for most home runs in a season for a shortstop.
"It felt pretty good in that situation," Peralta said. "I'm looking for that pitch over there and tried to be patient and got a good swing on it."
Marco Gonzales, mixing his fastball with an array of offspeed pitches, kept the Rockies off-balance after a shaky start to his outing. Gonzales struck out nine, three of which were looking.
"The curveball has been a big addition," Gonzales said. "I think my stint in Triple-A really helped with that, and then back up here, just focusing on throwing it and not trying to do too much with it. I got some swings and misses with it today and got some ground balls."
Gonzales improved to 3-2.
"He was good," Cardinals manager Mike Matheny said. "He got himself into some trouble at times, but he was able to work out of it. You look up there and only a few hits, he did have some walks and just some near misses and that's the kind of pitcher he is. He's so fine with the location of his fastball. There's times when we're going to need him to get it over the plate and let our defense work behind hm. It's just a terrific outing. We needed that big and he came up big."
It was a huge contrast to a whirlwind Major League debut for Gonzales against the Rockies on June 25. Gonzales gave up five runs in five innings in that start after being called up from Double-A on short notice.
"It helps when you're pitching for a first-place team in a pennant race," Gonzales said. "The goal was just to go out there and compete. My number was called and we came out on top today."
The nine strikeouts were the most by a Cardinals left-handed rookie since Rick Ankiel struck out 11 against Pittsburgh on Sept. 13, 2000.
The Cardinals' pitching staff tied a season high with 16 strikeouts. Five relievers combined to keep the Rockies off the board and Trevor Rosenthal picked up his NL-leading 44th save by striking out the side in the ninth.
"It starts with our starting pitching," Matheny said. "Marco did a great job and we have some guys in the 'pen that can get it done. They can get the strikeout all the way through the bullpen."
"The whole series we were pitching good," Cardinals catcher Yadier Molina said. "Hopefully, we will continue doing that."
Bourjos made a diving grab of a Josh Rutledge liner for the second out in the seventh. Drew Stubbs followed the catch with a triple, and he was stranded at third after reliever Carlos Martinez got Rafael Ynoa to ground out.
"He just makes it look easier than what it actually is," Matheny said of Bourjos. "He's a plus defender that can be a game-changer. It's nice to see him come through. He loves to go out there and make those kind of catches and he's one of the better I've seen."
St. Louis added an insurance run when Molina scored on a wild pitch in the eighth. More important for the Cardinals, Molina is showing signs of regaining his hitting stroke after missing nearly two months with a thumb injury. He went 3-for-4, including a double to deep center to set up the eighth-inning run.
"It's coming back, slowly, but it's coming back," Molina said. "It's going to take time. I have to be on top of that in my training, doing my exercises, but it's coming back."
Rockies starter Jordan Lyles went six innings and fell to 6-3. He gave up three runs on nine hits.
Colorado suffered another injury to an impact bat when Nolan Arenado left with a chest contusion. On Friday, the Rockies lost Justin Morneau to side soreness. Both are considered day to day.
With the win, the Cardinals' magic number to clinch the division was reduced to 10, but Matheny isn't looking past the next game against Milwaukee on Tuesday.
"We just got to keep putting our head down and playing good games," Matheny said. "Each night, I think we need to buy into the one-game series every single night. This was a big one. We needed this today and we completely controlled what we need to do by having a consistent, simple approach and it's worked. It's worked so far. It's got us to where we are. No sense in messing with it now and looking any further."