ST. LOUIS — While refusing to disrespect the Astros by labeling this three-game series as a should-be sweep, the Cardinals nevertheless know the benefits of their current and upcoming schedule.

A nine-game stretch that began on Tuesday and includes games against the Astros and Cubs presented the Cardinals with an ideal opportunity to create some separation in their quest to lock down the second National League Wild Card spot. While closest competitors Los Angeles and Milwaukee still have games on the docket Thursday, the Cardinals depart St. Louis knowing that they’ve done their part.

St. Louis finished off a three-game sweep, handing the Astros their 102nd loss with a 5-4 win on Thursday, the day the Cardinals organization surpassed the 3 million mark in attendance. In six games at Busch Stadium this season, Houston didn’t win once.

This sweep runs the Cardinals’ winning streak to four games and extends their lead over the Dodgers in the NL Wild Card race to 2 1/2 games.

The Astros missed several opportunities to put up a big inning, including in the first, when Cardinals starter Jaime Garcia allowed three of the first four batters to reach. The lefty struck out J.D. Martinez before walking home a run but left the bases full to avoid additional damage.

St. Louis answered immediately. First baseman Allen Craig connected for a three-run homer off Astros starter Bud Norris in the bottom half of the inning. Matt Carpenter and Matt Holliday preceded the blast with singles.

Houston did, however, swarm the bases all day. Three third-inning hits, the last of which caromed off second base in an unlucky break, allowed the Astros to tie the game at 3 against Garcia.

A pair of missed plays by third baseman David Freese in the sixth stirred another Astros rally. Garcia ended it with his 96th and final pitch of the day, which resulted in an inning-ending double play to leave a runner at third.

An inning later, reliever Edward Mujica induced an inning-ending double play with the bases loaded.

In between, the Cardinals inched back in front with help from Carlos Beltran, who had been kept out of the starting lineup in manager Mike Matheny’s effort to continue finding the right fielder regular rest. The intent, Matheny explained before the game, was to jump-start Beltran’s production by keeping him fresh.

The payoff was immediate. Summoned off the bench with two on and one out in a tied game, Beltran drove both teammates in with a sixth-inning double.

Mujica let the Astros pull back within one run with a three-hit seventh before ending the threat. Fernando Salas then came up big in the eighth. After Mitchell Boggs and Marc Rzepczynski walked the bases loaded, Salas entered and recorded back-to-back strikeouts. On the day, the Astros went 0-for-5 with the bases loaded.

That preserved the win for Garcia (5-7), who has given the Cardinals a quality start in each of his three home outings since coming off the disabled list.