NEW YORK, N.Y. - When Neil Walker homered on the fifth pitch of the game, it looked as if the Pittsburgh Pirates might tee off against Bartolo Colon.

It took them about three hours to score again. When they did, it was just enough.

Gregory Polanco singled home the go-ahead run in the 10th inning and Pittsburgh ended the Mets' seven-game home winning streak, stopping New York 3-2.

"There's not many games you go one in the first, don't score for eight innings and come back and put up two in the 10th," Pirates manager Clint Hurdle said. "Just playing good team baseball. Guys are in it."

It was 1-all going into extra innings. Polanco singled off Bobby Parnell (1-2) and Aramis Ramirez hit a sacrifice fly against Carlos Torres.

The NL East-leading Mets scored in the bottom half on Curtis Granderson's sacrifice fly before Mark Melancon finished for his 36th save.

"Outside of the 10th inning, it was a good ballgame," Mets manager Terry Collins said. "That was a very, very good ballgame."

Arquimedes Caminero (3-1) pitched a scoreless ninth for the win.

Walker homered with one out in the first, sending a drive into the Pittsburgh bullpen.

The playoff-contending Pirates homered in their eighth straight game for the first time in a single season since June 2013, STATS said.

Colon wound up pitching seven innings, giving up five hits while striking out seven.

Yoenis Cespedes hit his 20th home run overall, and second since being traded to the Mets from Detroit, with a tying drive in the sixth.

It was the Mets' 15th long ball in their last 19 games, and tied a Citi Field record with 67 homers in a season.

Making his second start joining the Pirates, J.A. Happ allowed seven hits in 5 1-3 innings.

"The bullpen came in and did an unbelievable job," Happ said. "It's been fun winning games and games that definitely mean a lot."

Backup catcher Chris Stewart led off the Pittsburgh 10th with a single and was pulled for pinch-runner Starling Marte, out of the starting lineup because of a bruised left hand.

Pinch-hitter Francisco Cervelli sharply singled to left on a full count, sending the speedy Marte to third. Polanco lined Parnell's first pitch up the middle.

"I enjoy it," Polanco said. "Everybody enjoys it when you have a big hit, the RBI, and go-ahead run."

Juan Lagares led off the Mets 10th with a double, and a wild pitch set up Granderson's sacrifice fly. Melancon struck out Cespedes and retired Juan Uribe on a grounder.

TRAINER'S ROOM

Pirates: Marte was held out of the starting lineup for the second straight night. The 26-year-old was removed from Wednesday's game in St. Louis after two at-bats because of discomfort. He was a pinch-runner Thursday, and played left field after pinch-running against the Mets. He is listed as day-to-day.

Mets: 3B David Wright (spinal stenosis) played in his third rehab game for Class A St. Lucie, getting two hits and going all nine innings in the field. ... 1B Lucas Duda (lumbar strain) took some swings in the indoor cage, fielded a limited number of grounders and participated in a full round of batting practice. He hasn't played in four games. "We'll just see how he's going to feel later and certainly hope that tomorrow might be a day that we can get him in there," Collins said.

UP NEXT

Pirates: Charlie Morton (7-4, 4.48 ERA), from Flemington, New Jersey, starts Saturday night. Pittsburgh has won the right-hander's last three outings despite a shaky performance on Sunday at PNC Park, where the Dodgers tagged him for five runs and 10 hits over five innings.

Mets: Jonathon Niese (7-9, 3.46) sports a 2.41 ERA over his last eight outings dating to June 30. The 28-year-old lefty is seeking his third consecutive win.

BOSS OF THE BUCCOS

The victory was the 400th of Hurdle's career with the Pirates, making him the ninth manager in franchise history to reach that milestone.

His overall managerial record, which includes parts of eight seasons at the helm in Colorado, is 934-986. Hurdle led the Rockies to the NL pennant in 2007 and was the 2013 NL Manager of the Year with Pittsburgh.