Pujols hit a two-run single in the third inning to push his career total to 2,218 RBIs. That came a night after he broke a tie with Babe Ruth for second place on the career list. Hank Aaron holds the record with 2,287.
Cardinals manager Oliver Marmol then removed the 42-year-old Pujols at the end of the inning. St. Louis opens postseason play Friday when it hosts a best-of-three National League wild-card series.
Juan Yepez gave the Cardinals the win when he hit a tiebreaking single with one in the 10th inning off Chase De Jong (6-3) to score automatic runner Ben DeLuzio.
''Tonight was interesting because you're fairly scripted in who you want to use and who you don't want to use and what you want tomorrow to look like so you can get ready for Friday,'' Cardinals manager Oliver Marmol said. ''It was a good one to still figure out a way to come out on top.''
The Cardinals threw out the potential tying run at home in the bottom of the 10th when automatic runner Kevin Newman tried to score from second base on Oneil Cruz's line single off the glove of first baseman Alec Burleson. The ball deflected to second baseman Brendon Donovan, who threw home to catcher Andrew Knizner.
The Pirates challenged the call, but it was upheld on video review.
''I thought we were going to get it overturned,'' Newman said. ''I just thought he didn't tag me until he got higher up on the body.''
It was the Pirates' 100th loss, the second year in a row they have reached that mark.
The Cardinals got two hits each from Donovan, Corey Dickerson, Knizner and Paul DeJong.
Cruz had three hits for the Pirates and Bryan Reynolds, Rodolfo Castro, Jack Suwinski, Ke'Bryan Hayes and Ji-Hwan Bae added two apiece. Miguel Andujar drove in two runs.
Chris Stratton (10-4) pitched two scoreless innings for the win.
''They weren't the prettiest two innings I've ever pitched but I got a great play from the defense in the 10th inning to help me out,'' Stratton said. ''It was a good play all the way around.'
Pujols' hit put the Cardinals ahead 3-1 but the Pirates answered with six runs in the bottom of the third. Andujar's run-scoring double highlighted an inning that includes RBI singles by Castro, Suwinski, Ben Gamel and Bae.
The Cardinals then scored four runs in the seventh inning to tie the score at 7-all. Donovan hit an RBI single, Dickerson drove in two runs with a double and the tying run scored on a throwing error by Cruz, the rookie shortstop.
Both starting pitchers lasted just 2 2/3 innings. The Cardinals' Dakota Hudson was rocked for seven runs and nine hits while the Pirates' JT Brubaker allowed three runs on four hits.
Brubaker was activated from the injured list before the game. He had been out since Sept. 16 with right lat discomfort.
Reliever Ryan Helsley, the Cardinals' closer, left in the eighth inning with a jammed right middle finger. Helsley was injured after catching a line drive by Bae and using his hands to brace himself while dodging a piece of a broken bat.
Helsley said he expects to be ready to pitch Friday.
''I don't think there was anything super wrong with it,'' Helsley said. `Just give it some rest and let it resolve itself.''
The Pirates optioned right-hander Roansy Contreras to Triple-A Indianapolis to clear a roster spot for Brubaker. They also recalled infielder/outfielder Tucapita Marcano from Indianapolis and optioned catcher Jose Godoy to the same club.
Center fielder Bryan Reynolds was voted the winner of the Roberto Clemente Award, emblematic of the Pirates' MVP, by the Pittsburgh chapter of the Baseball Writers Association of America.
Mitch Keller won the Steve Blass Award for best pitcher. Former infielder Michael Chavis was voted the Chuck Tanner Good Guy Award.
Cardinals: OF Tyler O'Neill (strained right hamstring) has been ruled out for the wild-card series but St. Louis is hopeful he can play in the NLDS round if it advances. . 3B Nolan Arenado (left quadriceps tightness) missed his second straight game but could play Wednesday.
Cardinals: Have not decided on a starter for Wednesday, though Marmol said LHP Matthew Liberatore (2-1, 5.46) and RHP Jake Woodford (4-0, 2.33) are possibilities.
Pirates: RHP Johan Oviedo (4-3, 3.12), who was acquired from the Cardinals on Aug. 1, gets the start.
More AP MLB: https://apnews.com/hub/mlb and https://twitter.com/AP-Sports
Copyright 2022 STATS LLC and Associated Press. Any commercial use or distribution without the express written consent of STATS LLC and Associated Press is strictly prohibited.