LOS ANGELES (AP) Aramis Ramirez hit a tiebreaking double in the eighth inning, Andrew McCutchen doubled home two runs and the Pittsburgh Pirates ended a four-game skid with a 3-2 victory over the Los Angeles Dodgers on Saturday night.

Pittsburgh climbed within four games of NL Central-leading St. Louis following the Cardinals' 5-4 loss at Chicago. The Pirates remained a game ahead of the Cubs in the race for the first wild card, with both teams comfortably in playoff position.

Despite the Dodgers' sixth loss in 24 games, their magic number for clinching their third straight NL West title dropped to seven because the San Francisco Giants lost 6-0 to Arizona.

More from FoxSports

Francisco Liriano (11-7) allowed two runs and five hits over seven innings, striking out nine. The left-hander is 7-1 with a 3.66 ERA in his last 14 starts.

Liriano also is 4-0 with a 2.73 ERA in five career starts against the Dodgers. His only other start at Chavez Ravine was on May 30, 2014, when he threw 5 2-3 scoreless innings in a 2-1 victory.

Liriano took a 2-1 lead into the seventh before the Dodgers tied it on an RBI double by A.J. Ellis. But the Pirates regained the lead in the eighth.

Gregory Polanco chased reigning NL MVP Clayton Kershaw (14-7) with a leadoff double and went to third on a groundout before Chris Hatcher intentionally walked McCutchen. Ramirez followed with a drive to the fence in left-center for his 71st RBI.

Tony Watson pitched a perfect eighth and Mark Melancon did likewise in the ninth for his major league-leading 47th save in 49 attempts, breaking the franchise record set by Mike Williams in 2002.

Kershaw was charged with three runs and seven hits in seven-plus innings. He struck out eight, raising his major league-leading total to 272 with three starts left in the regular season. The last time a pitcher fanned at least 300 in a season was 2002, when Randy Johnson did it for the fourth straight year with the Diamondbacks.

Kershaw was 9-0 with a 0.98 ERA in his previous 13 starts since losing at Miami on June 27. The three-time Cy Young Award winner finished the night with a 2.18 ERA, third in the National League. Dodgers teammate Zack Greinke has a major league-best 1.65 mark.

Dodgers second baseman Howie Kendrick, reinstated from the disabled list Friday after missing 34 games because of a strained left hamstring, played for the first time since Aug. 10 and hit an RBI single in the first inning. It was his 10th hit in 20 career at-bats against Liriano to that point.

McCutchen sliced a 3-2 pitch down the right-field line and just inside the chalk to give Pittsburgh a 2-1 lead in the second. The 2013 NL MVP has 95 RBIs, one shy of his career-best total in 2012. He came in with just two RBIs in 21 career at-bats against Kershaw.

TRAINER'S ROOM

Dodgers 3B Justin Turner exited after six innings because of left knee soreness.

UP NEXT

Pirates: RHP Gerrit Cole (16-8) has allowed only one home run in 54 2-3 innings over his last nine starts.

Dodgers: RHP Mike Bolsinger (6-3) makes his 28th career start and first against Pittsburgh.