PITTSBURGH -- Right-hander Shelby Miller, backed by a four-run first inning, got through 5 1/3 shaky innings to win his fourth consecutive start, and the St. Louis Cardinals slipped past the Pittsburgh Pirates 6-5 Sunday night.

St. Louis closer Trevor Rosenthal induced a game-ending double play with the bases loaded to earn his 10th save.

Miller (5-2) allowed two runs on four hits while walking four and striking out two. He has issued 31 bases on balls in 44 2/3 innings this season. He won each of his past two starts against the Pirates after losing his first five.

Rosenthal gave up center fielder Andrew McCutchen's RBI single in the ninth that made it a one-run game. The Pirates then loaded the bases with no outs, but first baseman Ike Davis fouled out and shortstop Jordy Mercer grounded into a 1-2-3 double play.

First baseman Allen Craig, catcher Yadier Molina and outfielder Jon Jay each had two of the Cardinals' 11 hits. Craig and Molina hit consecutive RBI singles in the first-inning outburst against starter Charlie Morton (0-5).

The Cardinals (19-19) salvaged the finale of the three-game series to avoid their first three-game losing streak of the season.

Morton's streak of winless starts reached 14 despite shutting down the Cardinals after the first inning and making it through the sixth. In all, he gave up four runs (one earned) and seven hits with one walk and three strikeouts.

Mercer hit a two-run home run and a double for the Pirates. Third baseman Pedro Alvarez had three hits, and catcher Tony Sanchez added two hits.

Pittsburgh's four-game winning streak, a season best, was snapped.

The Pirates trailed 4-2 before an RBI single by Alvarez in the seventh inning sliced the margin to one.

However, the Cardinals extended their lead to three runs with a two-run eighth inning. Center fielder Peter Bourjos, who entered an inning earlier as a defensive replacement, hit a run-scoring single, and a wild pitch by reliever Bryan Morris that allowed Jay to score.

A groundout by Sanchez drove in a run for the Pirates in the bottom of the eighth, cutting the deficit to 6-4.

The Cardinals struck for four first-inning runs off Morton, though only one was earned as Alvarez committed a throwing error while trying to start what would have been an inning-ending double play. Craig, Molina and second baseman Mark Ellis contributed run-scoring singles, and first baseman Matt Adams hit a sacrifice fly.

Mercer cut the Pirates' deficit to 4-2 in the fourth inning when he hit a two-run home run, his first of the season, to left field off Miller.

NOTES: Pirates CF Andrew McCutchen returned to the lineup after missing Saturday's game with soreness in his left ankle. He went 1-for-2 with three walks. ... Pittsburgh LF Starling Marte was not in the lineup because of lower back tightness, which caused him to leave Saturday's game in the fourth inning. ... Pirates RF Travis Snider batted leadoff after missing the previous two games while serving a suspension from Major League Baseball for his actions April 20 in a benches-clearing brawl with the Milwaukee Brewers. ... St. Louis CF Peter Bourjos was out of the starting lineup because of a cut on his right wrist, though he entered as a sub. He was spiked Saturday while attempting to break up a double play. Jon Jay, who entered the game 8-for-16 in his career against Pittsburgh RHP Charlie Morton, started in center field and went 2-for-4. ... The Cardinals host the Chicago Cubs on Monday night in the opener of a four-game series with St, Louis LHP Tyler Lyons (0-2, 3.45) facing LHP Travis Wood (2-4, 4.75). ... The Pirates are off Monday before beginning a three-game series Tuesday night at Milwaukee.