PITTSBURGH -- The San Diego Padres are nowhere near a pennant race. Not by a long shot.

Too bad. They have apparently gotten the hang of playoff baseball.

Logan Forsythe and Rene Rivera delivered consecutive RBI singles in the ninth inning off Pittsburgh closer Mark Melancon and the Padres rallied for a 3-2 victory on Wednesday night for their third straight win.

"What a game," San Diego manager Bud Black said. "Pitch to pitch, every pitch counted. Just a great, great game."

Forsythe's single to right scored pinch-runner Andrew Cashner to tie the game and Rivera's blooper brought home Chris Denorfia as the Padres dealt Pittsburgh's NL Central title hopes another blow as the Pirates fell two games behind first-place St. Louis, which beat Colorado 4-3.

Dale Thayer (3-5) picked up the win in relief. Huston Street pitched a perfect ninth for his 33rd save as San Diego improved to 31-10 at PNC Park since it opened in 2001.

"There is no rhythm or reason to it," Black said. "If we knew why, we would try to bottle it and take it with us wherever we go. I wish I could try to explain it."

The Pirates would certainly like one.

Melancon (2-2), who inherited the closer's role when All-Star Jason Grilli went out with a forearm injury in July, blew his third save of the season.

"Just got to tip your hat, they put the ball in play and found some holes," Melancon said. "They did a good job. Sometimes it happens that way."

Andrew McCutchen hit a two-run homer in the seventh to give the Pirates the lead but Pittsburgh fell to 74-3 when leading after eight when Melancon faltered.

Melancon has been nearly automatic since taking over for Grilli before running into trouble in the ninth.

Jedd Gyorko led off with a single before Melancon settled down to retire the next two batters. Denorfia singled to put runners on the corners and Forsythe and Rivera followed with well-placed, if not exactly well-struck, hits to right field as San Diego improved to 11-4 in its last 15 games.

"It was something special," Rivera said. "We battled all game and we came through."

The rally spoiled McCutchen's latest heroics. Pittsburgh was handcuffed by San Diego starter Tyson Ross for 6 1/3 innings when Neil Walker reached on a wild pitch with one out in the seventh. McCutchen followed by turning on a 3-0 fastball, sending it into the seats in right-center for his 20th homer of the season.

The Pirates lit up Ross for five runs in 6 1/3 innings in San Diego a month ago but came in having scored just two runs in the first two games of the series, losses that dropped Pittsburgh behind the Cardinals as they pursue their first division title in 21 years.

Justin Morneau singled leading off the second before being erased on a double play. Ross spent the next 90 minutes toying with the Pirates. Pittsburgh only managed to get three balls to the outfield through six innings.

Ross retired Starling Marte to start the seventh and Walker swung and missed at strike three. The ball skittered away from Rivera and rolled to the backstop, allowing Walker to reach. Ross threw wide on three straight pitches to McCutchen, and the National League MVP candidate mashed a fastball over the heart of the plate well over the wall.

It was the only mistake on an otherwise brilliant night by Ross, who allowed two runs on three hits with seven strikeouts.

"Tyson pitched a great game and he certainly didn't deserve to lose," Black said. "He was more efficient in the strike zone, he was aggressive in the strike zone, he was throwing more strikes and he got in better counts. When you do those things and you have good stuff then you have games like this."

Tyson got a good look as McCutchen trotted around the bases then came out for a curtain call as the suddenly energized crowd of over 27,000 roared. He managed to get through the seventh without further damage, ending a duel with Pittsburgh's Charlie Morton.

Mixing his sinker with an improved curveball in his comeback from Tommy John surgery last year, Morton tied a career-high with nine strikeouts, allowing only one run and two hits.

Game notes
Pittsburgh sat C Russell Martin on Wednesday and will do so again on Thursday. Manager Clint Hurdle said he wants Martin to be well rested when the Pirates open a pivotal three-game series with Cincinnati on Friday. ... The series wraps up Thursday. Gerrit Cole (8-7, 3.33 ERA) starts for the Pirates against Ian Kennedy (6-9, 4.85).