DENVER (AP) Pedro Alvarez hit a go-ahead, three-run homer in the eighth inning, and the Pittsburgh Pirates earned their 10,000th win since joining the National League, beating the Colorado Rockies 5-4 on Thursday.

A day after clinching a playoff spot for the third straight season, the Pirates reached another momentous milestone. They're fifth all-time in NL wins behind San Francisco, Chicago, Atlanta and Los Angeles, according to STATS.

Starling Marte collected four singles and finished 13 for 20 in the four-game sweep. It's the most hits in a four-game series for a Pirates player since Pie Traynor had 13 in 1928.

More from FoxSports

Alvarez had the big hit when he lined a fastball from Jairo Diaz (0-1) over the fence in right field.

Reliever Joe Blanton (5-0) earned the win for a second straight game. Mark Melancon pitched a perfect ninth to pick up save No. 50. He becomes the seventh NL closer to reach that total in a season.

Trailing 4-2 heading into the eighth, Marte and Neil Walker had one-out singles. After a strikeout, the stage was set for Alvarez. It was his 26th homer of the season.

Nolan Arenado had a two-run double in his return to the lineup. He sat out Wednesday after banging his head on the dirt when he dove for a ground ball Tuesday.

The Pirates entered the day four games behind first-place St. Louis in the NL Central. They rested third baseman Aramis Ramirez (groin) and Gregory Polanco (knee) with a big series in Chicago against the Cubs starting Friday.

Cristhian Adames broke a tie in the fifth with an RBI triple into the left-center gap that scored Corey Dickerson.

Chad Bettis was in line for the win after allowing two runs over six innings, but the bullpen couldn't hold it.

Jeff Locke threw 5 2-3 innings and gave up four runs in his 30th start this season, which matches his career high.

PITTSBURGH HISTORY

Pittsburgh played in the American Association for several seasons before joining the NL in 1887. They won their first game on April 30, 1887.

TRAINER'S ROOM

Pirates: Polanco said his right ankle was fine even though it bent awkwardly as he went into second base Wednesday. His knee didn't fare quite as well.

Rockies: OF Brandon Barnes could be done for the season after straining his left hamstring Wednesday. ... OF Charlie Blackmon missed a second straight game with neck stiffness.

UP NEXT

Pirates: RHP Gerrit Cole (17-8, 2.64) gets the start Friday when Pittsburgh opens a pivotal three-game series in Chicago against the Cubs. Cole is 3.10 with a 3.10 ERA in eight career starts against Chicago.

Rockies: RHP David Hale (4-5, 6.32) takes the mound Friday as Colorado begins a three-game series against the Dodgers, who lead the NL West and can lock up the division title this weekend.