Carpenter deposited an 0-2 pitch from Phillies right-hander Seranthony Dominguez (1-1) just inside the right-field foul pole with two outs in the ninth.
Tommy Pham and Kolten Wong added solo homers for the Cardinals.
Odubel Herrera and Carlos Santana homered for Philadelphia, the 11th for each.
Velasquez was removed with a 4-2 lead in the seventh after giving up a one-out single to Yairo Munoz and hitting Wong with a pitch. Right-hander Tommy Hunter (2-1) retired Greg Garcia on a fly to left before allowing Carpenter's tying two-run double to right-center field.
The score was knotted at 1 in the third when Pham delivered a two-out homer by knocking a 1-1 slider 414 feet over the fence in left-center field for his 12th home run of the season.
Herrera put the Phillies back on top with one out in the bottom of the third when he sent a first-pitch curveball over the right-field fence. Herrera has gone deep in three straight games and in four of the past five.
Wong deposited a 2-1 fastball high in the air and over the fence in right to open the fifth to bring St. Louis back within one. It was his fifth homer of the season.
Santana got the run back in the bottom of the inning with his own leadoff blast, lining a 1-2 pitch over the fence in right.
Phillies third baseman J.P. Crawford was hit by a 94 mph fastball in the fourth inning and was replaced by Maikel Franco. After the game, the Phillies revealed that Crawford broke his left hand and is expected to miss four to six weeks.
(This story has not been edited by Devdiscourse staff and is auto-generated from a syndicated feed.)