Ankiel's two-run triple off Lidge capped a three-run rally in the ninth inning and the Cardinals beat the Astros 4-3 Sunday night.
Ankiel, breaking out of a slump that coincided with reports linking him to human growth hormone, had his second straight three-hit game. He's batting .433 (13-for-30) against the Astros with six RBI.
"It was exciting, especially being the last game here, just to get the win the way it unfolded," Ankiel said. "It was fun, and I hope the fans enjoyed it."
Albert Pujols also drove in a run in the ninth with a pinch-hit single that gave him 99 RBI. Last year's World Series winners won for only the fourth time in 18 games, two days after they were eliminated from postseason contention.
"That was just the way we wanted it, get your closer out there to close it out," Astros interim manager Cecil Cooper said. "Unfortunately Brad just had a little problem locating.
"I'm still going to sink or swim with Brad Lidge."
Kelvin Jimenez (3-0) got the last out in the ninth after a two-run homer by Carlos Lee off closer Jason Isringhausen had given Houston the lead.
Pujols missed his fifth straight start with a strained left calf muscle and can't run. He had plenty against the pitcher who surrendered a go-ahead homer to Pujols in the 2005 NLCS that brought the series back to St. Louis for a deciding sixth game.
"Sometimes that's going to happen," Pujols said. "In some big situations you're going to get big hits against big pitchers like that.
"But I'll take him anytime on my team, he's a great closer."
Lidge (5-3), who blew his eighth save in 24 chances, also walked Pujols on four pitches to force in a run with two outs in the ninth of the Astros' 6-4 victory on Friday.
"I knew Albert would come up at some point that inning, so getting guys on base, that's what kind of killed me," Lidge said. "There's not a lot of room for error with him, but at the same time, it's a situation where I had to go after him."
Lidge said the pitch to Ankiel was a slider down in the zone.
"It was a pitch I wanted, but he did a good job of putting it play," he said.
Lidge ran into trouble quickly Sunday, and failed to record an out. He surrendered a leadoff single to Miguel Cairo and walked pinch-hitter Ryan Ludwick before Pujols hit a long single off the left-field wall. Ankiel fouled off a pair of 1-2 pitches before hitting a liner into the right-field corner.
"I was just up there trying to battle," Ankiel said. "He throws so hard it's hard to just sit on a slider and with runners on and no outs I was just trying to get something to the outfield or something I could put hard contact on."
Brian Barden, pinch running for Pujols, easily scored the winning run.
Roy Oswalt allowed an unearned run in seven innings and Craig Biggio singled to move into a tie for 20th place on the career list with 3,055 hits for the Astros. Houston fell to 10-14 under Cooper.
It was likely the final game in St. Louis for Biggio, who has said he's retiring after this season -- his 20th in the bigs. The Busch Stadium crowd saluted him with a long ovation during his final at-bat in the eighth.
Todd Wellemeyer allowed one hit in five scoreless innings for the Cardinals, who were 4-7 on their final homestand.
Lance Berkman's liner ticked off Cardinals shortstop David Eckstein's glove for an error to start the ninth. Lee followed with his 31st homer, easily clearing the left-field wall on a 1-1 pitch from Jason Isringhausen.
Isringhausen has 30 saves in 32 chances but has struggled lately in non-save situations. He has allowed four runs in 2 2/3 innings his last three outings, also allowing a homer to the Phillies' Aaron Rowand on Sept. 17, while pitching in a game the Cardinals trailed by a run.
The Cardinals were 43-38 at home and completed a second season of uninterrupted sellouts, totaling a franchise record 3,551,778. The former record was 3,538,948 in 2005. ... Astros rookie Josh Anderson was 0-for-4, ending a nine-game hitting streak. ... Cardinals reliever Russ Springer's scoreless-inning streak ended at 17 2/3 innings, longest on the team this year, when he gave up Mark Loretta's tying single in the seventh.