James McDonald threw six shutout innings Friday and four Pittsburgh relievers preserved a 2-1 win over St. Louis in the opener of a critical series.

The Pirates and Cardinals, having fallen behind the hot Cincinnati Reds in the National League Central race, are both battling for a wild-card position.

Pittsburgh, which won its second straight but has just three victories in its last nine outings, moved two games in front of the Cardinals for second place in the division.

McDonald (11-5) gave up only two hits and won for the first time since July 18. This was his fifth start since that victory.

Reliever Chris Resop gave up the lone St. Louis run in the seventh, but Juan Cruz, Jason Grilli and Joel Hanrahan combined to retire all seven Cardinals they faced. It was the 34th save for Hanrahan.

Both Pittsburgh runs scored in the fourth, Travis Snider coming in on a wild pitch and Andrew McCutchen racing home on a passed ball.

Those two runs were given up by Jake Westbrook, who allowed six hits and three walks in 7 2/3 innings to absorb the loss.