Updated

Pittsburgh, PA (SportsNetwork.com) - Allen Craig and Yadier Molina posted a pair of hits to go with an RBI and run scored and the St. Louis Cardinals hung on to beat the Pittsburgh Pirates, 6-5, in the finale of a three-game set.

Trailing by two runs going into the ninth, Pittsburgh got a run back when Neil Walker hit a double and Andrew McCutchen singled to plate him and make it 6-5.

The Pirates later loaded the bases with none away, but Trevor Rosenthal got Ike Davis to pop out into foul territory and Jordy Mercer to roll into a 1-2-3 double play to end the game and give Rosenthal his 10th save of the season.

"That was beyond impressive what Trevor was able to do there at the end to get it back together. That's why he is pitching at the end of games," Cardinals manager Mike Matheny said of Rosenthal.

Shelby Miller (5-2) allowed two runs on four hits and four walks over 5 1/3 innings for the Cardinals, who avoided being swept.

Mercer smacked a two-run homer and a double for Pittsburgh, which had its four-game winning streak snapped. Charlie Morton (0-5) gave up four runs -- one earned -- on seven hits and one walk over six innings in defeat.

The Cardinals raced out to a comfortable lead following a four-run first, but Pedro Alvarez's two-out RBI single in the seventh trimmed the Pittsburgh deficit to 4-3.

St. Louis answered and tacked on a pair in the eighth to increase its advantage to 6-3.

Matt Adams and Jon Jay posted one-out singles before Mark Ellis struck out. Peter Bourjos then slapped a base hit into right to bring home Adams, and Jay scored on a Bryan Morris wild pitch.

Davis singled and Mercer doubled to start the home half before Davis scored on Tony Sanchez's RBI groundout, which cut the margin to 6-4.

Earlier, Craig, Molina and Ellis tallied RBI singles in the opening frame, with Adams' sacrifice fly accounting for the other run in the four-run inning. Mercer smacked a two-run shot into left in the fourth to trim the gap in half, 4-2.

"I just tried to get back out there and put up zeroes after that first inning," Morton said.

Game Notes

The Cardinals were 4-for-11 with runners in scoring position, while Pittsburgh finished 2-for-11 with RISP and left 11 men on base ... Mercer's homer was his first of the year.