Brandon Cumpton pitched seven shutout innings Sunday, working his way through the Chicago Cubs lineup on the way to a 2-1 win at Wrigley Field.

The Cubs made things interesting in the ninth, scoring a run off closer Mark Melancon.

The Pirates (37-38) got a third-inning home run by Travis Snider and an RBI single by Josh Harrison to take the series, 2-1, from last-place Chicago.

Cumpton, who has won three of his past four outings, went seven innings, giving up just two hits and two walks. He struck out four and threw just 87 pitches, 55 strikes.

“It’s a great example of the way these guys have come into the rotation and stepped up, moved in, and they’re pitching really well for us,” manager Clint Hurdle said. “They stabilized the rotation. We’ve pitched much better through the month of June. We knocked our starter’s ERA down, and have just been more efficient all over the place.”

Cumpton has had eight starts since being called up from Class AAA in late May.

“It’s about getting back to my strengths,” he said. “Got ahead in the count, and tried to put guys away early. … A little bit early on we had some fly balls, and later on we started getting ground balls and guys were making plays for me. I didn’t even know what my pitch count was until I got done. I felt like I threw a lot more than I did.”

He gave up his first hit in the first, but stranded the runner with back-to-back popups. He walked a batter in the fifth, but closed out the inning with a double play.

The Cubs threatened in the sixth when starter Jason Hammel hit a one-out single and Cumpton walked Chris Coghlan.

But he got a popup and grounder to short to end the inning.