Updated

Andrew McCutchen drove in three runs during a three-hit night and Mark Melancon survived a shaky ninth inning to help the Pittsburgh Pirates down the Texas Rangers, 5-4, in an interleague matchup with playoff implications.

Melancon gave up four consecutive two-out hits in the ninth, with Ian Kinsler and Alex Rios each singling in a run to pull the Rangers within a run.

With the tying run on third and the winning run on first, Melancon bore down and struck out the dangerous Adrian Beltre on three pitches, getting the slugger to chase a high fastball to secure his 13th save of the year.

"At the end of the day, he struck out the side, with a little action in between," Pirates manager Clint Hurdle said of Melancon.

Francisco Liriano (16-7) shook off a shaky start in his last outing and allowed just one run on six hits with two walks for the NL wild card-leading Pirates, who have won the first two meetings of the three-game series.

Jordy Mercer had four of Pittsburgh's 12 hits and Gaby Sanchez went 2-for-4 with an RBI as the Pirates ended the six-start winning streak of Martin Perez (9-4), touching the rookie lefty for four runs and nine hits over his five- plus innings on the hill.

"We grinded all night, it was just a matter of getting a base hit in the right situation," Texas manager Ron Washington said.

Pittsburgh still trails the Central-leading St. Louis Cardinals by one game.

The Rangers fell to 2-7 in September after going 20-7 last month, but with Oakland also losing on Tuesday they remain two games back in the AL West race.

The visitors opened the scoring in the third, though the run probably would not have counted if advanced instant replay were used for questionable plays, as it will next year.

With runners on the corners and one out, McCutchen hit a comebacker that struck Perez in the leg. Perez recovered the ball near third base and was a second slow in getting Tony Sanchez as he crossed the plate. Replay, however, showed Sanchez never touched home, instead stepping on A.J. Pierzynski's foot while it was on the plate.

Despite a brief dispute from Pierzynski, the Pirates went ahead 1-0 and added three more in the fifth -- all with two outs.

Mercer started the rally with a double into the left-field corner, and McCutchen followed with an RBI single to left. Marlon Byrd kept the inning going with a single, and Gaby Sanchez tacked on another run with a base hit before Byrd scored on a wild pitch.

Liriano, who surrendered seven runs in just three innings against the Brewers last Wednesday, kept the Rangers off the board until Kinsler doubled in Joey Butler with two away in the fifth.

Beltre added an RBI single in the eighth, which ended with Jeff Baker striking out with runners on second and third.

The missed opportunity was costly, as McCutchen recorded his third RBI single of the night in the ninth for what proved to be the game-deciding run.

Game Notes

Liriano, who has recorded a decision in all 23 of his starts this year, became the first Pittsburgh left-hander to win more than 15 games in a season since John Smiley (20) and Zane Smith (16) in 1991 ... McCutchen is hitting .421 (45-for-107) with 22 RBI in his last 27 interleague games ... The Rangers have scored five runs or less in 11 straight games, their longest stretch since an 11-game string from May 13-23, 2011 ... The Rangers had 13 hits ... Texas has lost a season high-tying four straight series.