Gerrit Cole pitched seven strong innings to become the major leagues' first 13-game winner and Neil Walker had a two-run homer among his three hits as the Pittsburgh Pirates beat the St. Louis Cardinals 5-2 on Friday night.

Cole (13-3) allowed two runs — both on Matt Carpenter's third-inning home run — and six hits while striking out three and walking two. He became just the second Pirates pitcher to win 13 games before the All-Star break, joining Dock Ellis, who had 14 in 1971.

Walker's home run, his seventh, extended the Pirates' lead to 5-2 in the fourth inning.

Mark Melancon pitched a scoreless ninth for his National League-leading 29th save in 30 opportunities.

The Pirates (51-35) won for the sixth time in seven games and drew within 4 ½ games of the Cardinals (56-31) in the NL Central in the second game of a four-game series between the teams with the best records in the major leagues.

Jung Ho Kang and Jordy Mercer each had two of the Pirates' 10 hits.

Lance Lynn (6-5) lasted just four innings as he lost for the first time in seven starts. He was tagged for five runs and nine hits with five strikeouts and one walk.

Lynn has beaten the Pirates only once in his last nine starts.

The Cardinals' Jhonny Peralta and rookie Tommy Pham had two hits apiece.

The Pirates went ahead 3-2 in the third inning on RBI singles by Kang and Pedro Alvarez.

Carpenter's ninth homer put the Cardinals ahead 2-1 in the top of the third, coming after a double by Pham.

Mercer doubled home the game's first run in the first inning.