LOS ANGELES (AP) Starling Marte hitting a tying home run off Mike Bolsinger, Pedro Alvarez had a go-ahead homer and the Pittsburgh Pirates beat the Los Angeles Dodgers 4-3 Sunday to open a two-game lead over the Chicago Cubs for the NL's first wild-card berth.

Gerrit Cole (17-8) allowed three runs and six hits in seven innings and struck out nine, improving to 3-0 in four career starts against Los Angeles. Tony Watson and Mark Melancon followed with perfect innings of relief, and Melancon got his 48th save in 50 chances.

Pittsburgh, which trails NL Central-leading St. Louis by four games, is a big league-best 34-17 in one-run games and improved to 23-6 against the NL West.

More from FoxSports

Bolsinger (6-4) gave up four runs - three earned - and five hits in 4 1-3 innings. The Dodgers' magic number for clinching their third straight NL West title stayed at seven. Los Angeles fell to 17-17 against the NL Central.

Marte's 17th homer this season tied the score 2-2 in the third, a drive halfway up the pavilion seats in left-center, and Alvarez hit his team-high 25th homer to put Pittsburgh ahead in the fourth. Twenty of Alvarez's homers have come with the bases empty

Aramis Ramirez greeted Yimi Garcia with an RBI single that made it 4-2 in the fifth. Scott Van Slyke homered in the seventh inning, only the second allowed by Cole in 61 2-3 innings over his last 10 starts.

The top overall pick in the 2011 amateur draft, Cole has 38 big league wins. He made his major league debut on June 11, 2013, and since then only Zack Greinke (47), Clayton Kershaw (46) and Madison Bumgarner (44) have more victories.

BIG ARM

Marte threw out Alex Guerrero in the second when Guerrero tried to stretch his RBI single to left into a double. Marte leads the NL with 15 outfield assists, and the Pirates top the league with 35.

UP NEXT

Pirates: RHP A.J. Burnett (8-5) will start the opener of a four-game series on Monday night at Colorado, his first start against the Rockies in more than two years.

Dodgers: LHP Brett Anderson (9-8) will start the opener of a four-game set against Arizona. He leads the majors in ground-ball percentage (66.7) and grounder-to-fly ratio (4.29).