Wednesday's victory stopped a three-game losing streak.
Pagan's homer capped the scoring with no outs in the bottom of the eighth, following an earlier a sacrifice fly and an RBI triple.
David Wright also had three hits, including a first-inning two-run homer.
Winner Nelson Figueroa hit a two-run triple in the second, while Alex Cora added one RBI for the Mets, who have won only twice in their last six games.
Figueroa (1-2) replaced injured starter Jonathan Niese, who injured his right hamstring while covering first base on a Joe Thurston grounder in the second.
Thurston and Albert Pujols had two hits apiece for the Cardinals, who fell out of first place in the NL Central.
The losing pitcher was starter Kyle Lohse (4-7).
Duggar sisters unveil Christian dating rules in new book
Astronomers offer more expansive view of universe