Adams doubled to deep right and Peralta brought him home with a single in the 10th inning and the Cardinals survived 7-6 Friday night to stay alone atop the NL Central.
"That's a big win," said reliever Pat Neshek. "That's a huge, huge win, and tomorrow I think it's going to really carry over."
With Pittsburgh winning 3-1 at Cincinnati, the Cardinals remain a game up on the Pirates, with two to play.
The game came hours after the Diamondbacks announced manager Kirk Gibson had been fired.
"We gave them a nice little run tonight," said bench coach Alan Trammell, filling in as manager over the weekend. "We were just again, probably a broken record, a little short. Give our guys a lot of credit for battling."
Neshek, superb all season but struggling some recently, gave up three runs that tied it for Arizona in the sixth. Two of the hits were bloop singles. The second of them, by Didi Gregorius, brought in two runs.
"It seemed like everything was just out of reach," Neshek said.
Ender Inciarte followed with a sharp hit to left that, to the good fortune of the Cardinals, bounced into the seats for an RBI ground-rule double. Gregorius, who had crossed the plate with what would have been the go-ahead run, had to go back to third.
But the Cardinals didn't let this one get away.
"I think we just believe we're going to pick each other up," St. Louis manager Mike Matheny said. "You know Pat Neshek's picked us up all season long and been as good as anybody in that eighth inning. Just a couple things not going his way put us in a tough spot."
Marco Gonzales (4-2) shut down the Diamondbacks in the ninth to set the stage for the Cardinals' 10th-inning success.
"It was an interesting kind of feel in the dugout," Matheny said. "We got out of that inning with Marco, you could just tell something was going to happen."
Peralta also had a two-run double in a game St. Louis led 6-3 going into the eighth.
Evan Marshall (4-4) took the loss.
Trevor Rosenthal pitched a perfect 10th for his 45th save in 51 opportunities.
St. Louis was trailing 2-1 in the sixth inning when Peralta launched a bases-loaded double over the head of A.J. Pollock in deep center, bringing in two runs. Yadier Molina followed with a sacrifice fly and it was 4-2. The Cardinals added two more in the seventh
Cardinals: Wacha pitched 4⅔ innings in his previous start after skipping an outing for rest and work on his conditioning following his long stay on the DL. He missed 68 games due to a stress reaction in his right shoulder.
Diamondbacks: INF Chris Owings was a late scratch as a precautionary measure due to a sore left shoulder. ... Arizona is finishing the season with five on the DL, four due to Tommy John surgery -- Bronson Arroyo, Patrick Corbin, David Hernandez and Matt Reynolds.
Cardinals: RHP Lance Lynn (15-10) makes his team-leading 33rd start of the season with the Cardinals needing a victory to clinch at least a tie for first in the division. Lynn is one shy of 50 career wins.
FIRED BUT STILL HERE
Sometimes fired doesn't mean fired right this minute.
Trammell was fired along with Gibson. But Trammell is still working. He agreed to manage the Diamondbacks' final three games.
"I will finish things up and then I will be on my way," he said. "Then you will probably see me somewhere else, who knows?"
Kevin Towers is still in the organization three weeks after being dismissed as general manager.
With the loss, the Diamondbacks (63-97) have dropped eight of nine and are guaranteed to finish the season with the worst record in the majors, and the first pick in next year's draft.
The Cardinals were not swept in a series all season.