Updated

The calendar is about to turn to August, and the Pittsburgh Pirates own a 2 1/2-game lead in the National League Central.

Russell Martin came through with the deciding hit, a tie-breaking single in the bottom of the eighth inning, and the die-hard Pirates lengthened their lead atop the division with a 5-4 come-from-behind decision over the slumping St. Louis Cardinals at PNC Park.

Martin, Neil Walker and Clint Barmes each finished with two hits and an RBI to help Pittsburgh twice battle back from two-run deficits, while the bullpen turned in five scoreless innings to offset an uncharacteristic rough outing from starter Jeff Locke.

The Pirates have now taken the first four tests of this critical five-game set between the NL Central's top two clubs and won five of six overall.

"It feels great...but there's still a lot of baseball left," Walker said.

St. Louis, on the other hand, was dealt its seventh consecutive defeat after failing to hold on to a 4-2 lead after 3 1/2 innings. It's the Cardinals' longest losing streak since a seven-game slide during June of their eventual 2011 World Series championship season.

The Cardinals will also have to deal with the absence of Yadier Molina for at least the next two weeks, with the team placing the All-Star catcher on the disabled list prior to the contest due to a strained right knee.

Matt Holliday went 3-for-5 with two RBI and Carlos Beltran had a pair of hits and two runs scored for St. Louis, but Trevor Rosenthal (1-2) was reached for a run on two hits after taking over for Adam Wainwright to start the bottom of the eighth.

Wainwright worked the first seven innings, allowing four runs on eight hits. Locke lasted just four frames and was tagged for four runs on 10 hits despite fanning six.

Holliday's third hit of the night, a single to right in the top of the fourth that brought home Beltran, gave St. Louis a 4-2 edge, but the Pirates battled back with single runs in their next two at-bats.

Barmes smacked a line-drive double that scored Alex Presley from first in the bottom of the fourth, and Starling Marte reached on a bunt single an inning later prior to stealing second and moving up on a Walker groundout. Andrew McCutchen then flied out to center, with Marte beating Jon Jay's throw home to create a 4-4 tie.

The score stayed that way until the bottom of the eighth, when Walker greeted Rosenthal with a single and later alertly tagged up on Pedro Alvarez's fly to left for the second out.

Martin then hit a hard smash that got under the glove of Cards' shortstop Peter Kozma as Walker raced home without a throw.

Mark Melancon set St. Louis down in order in the ninth to notch his fifth save, following a pair of two scoreless-inning stints from fellow relievers Vin Mazzaro and Tony Watson (3-1).

"This is definitely not what we wanted to do on this road trip," Wainwright said. "There's no panic, but at the same time we're urgent to go out there and win games. We're not taking this lightly."

The Cardinals, who had mustered a total of just six runs during their six straight losses coming in, had the bats working early on against a laboring Locke.

Three straight one-out singles from Beltran, Allen Craig and Holliday staked St. Louis to a 1-0 first-inning lead, and Daniel Descalso delivered a base hit up the middle later in the frame to plate Craig and increase the margin.

Wainwright issued a rare leadoff walk to Marte to begin the bottom of the first, however, which proved costly after Alvarez laced a two-out single to center that cut Pittsburgh's deficit to 2-1.

Holliday just missed a home run on a smash that hit the very top of the left- field wall to start the third inning, then scored St. Louis' third run after stealing second and advancing two bases on a Descalso infield hit and Tony Cruz's groundout.

Pittsburgh countered in its half of the inning, though, when Walker hammered a Wainwright curve into the seats in right to restore the one-run differential.

Beltran doubled with one out in the fourth and came around on Holliday's single to briefly restore St. Louis' two-run cushion.

Game Notes

Pittsburgh's bullpen has been charged with just one run allowed over the last seven games, spanning 19 1/3 innings ... The Cardinals also placed outfielder Shane Robinson (right shoulder strain) on the 15-day DL prior to the game, with outfielders Adron Chambers and Brock Peterson both recalled from Triple-A Memphis ... Craig's first-inning single ended an 0-for-22 skid at the plate, while Descalso halted an 0-for-16 stretch with his RBI hit in the opening inning ... Locke had permitted two earned runs or fewer in eight straight starts dating back to June 9 ... The Pirates acquired infielder Robert Andino from Seattle for a player to be named later or cash on Wednesday.