Updated

Zack Cozart smacked a go-ahead RBI double with two out as part of a two-run ninth inning as the Cincinnati Reds rallied past the Pittsburgh Pirates, 4-3, in the finale of a three-game set.

Trailing 3-2 entering the ninth, pinch-hitter Xavier Paul greeted Pittsburgh closer Joel Hanrahan (5-2) with a leadoff homer over the 21-foot wall in right field.

Two batters later, pinch-hitter Ryan Ludwick ripped a double to left, which preceded Cozart's two-bagger to left field that plated pinch-runner Denis Phipps.

Sean Marshall (5-5) spun a 1-2-3 eighth to pick up the win and Aroldis Chapman struck out two during a scoreless ninth and tallied his 37th save of the season.

The Reds are tied with the Washington Nationals for the top seed in the National League. The Nationals lost to the St. Louis Cardinals later on Sunday.

The win also gave Cincinnati at least the NL's No. 2 seed and home-field advantage during the NLDS.

Gunning for the club's first 20-game winner since Danny Jackson in 1988, Johnny Cueto surrendered three runs -- one earned -- on six hits in seven innings.

"I really, really want to give Johnny every opportunity to get 20 wins, but it was just one of those things that didn't work out," Reds interim manager Chris Speier said.

Garrett Jones hit a two-run homer for Pittsburgh, which notched its 20th straight losing season.

Pittsburgh was 63-47 on Aug. 6, but has gone just 14-35 since.

"One of my goals when I got here was to re-bond this city with this baseball team and to be a group of men who do that collectively. So it's definitely disappointing, especially when we were able to get to a certain point of the year where we were talking playoffs," Pirates manager Clint Hurdle said.

The Reds struck first with two runs in the third.

Following back-to-back singles by Brandon Phillips and Wilson Valdez, Joey Votto brought Phillips home with a ground-rule double to left field and Valdez scored on a Todd Frazier groundout.

Jones' blast in the home half tied the game at 2-2, and the Pirates went ahead with a run in the fifth on Andrew McCutchen's RBI single to left-center field.

Game Notes

Hanrahan's blown save was his fourth of the season ... Cincinnati was 2-for-9 with runners in scoring position, while the Pirates finished 2-for-8 with RISP ... Jones' homer was his 26th of the year.