New York Mets' Wilmer Flores drives in a run with...

New York Mets' Wilmer Flores drives in a run with a single off Pittsburgh Pirates relief pitcher Cory Luebke during the 10th inning of a baseball game against the Pittsburgh Pirates in Pittsburgh, Wednesday, June 8, 2016. The Mets won 6-5. Credit: AP/ Gene J. Puskar

PITTSBURGH — Terry Collins rubbed the tiny scratches on his cheek, the remnants of a tense Wednesday night. The nicks were a small price to pay, especially when weighed against the other alternative he considered: gouging his own eyes out.

To be sure, the manager was tempted plenty of times as the Mets sweated out a wrenching 6-5 win over the Pirates in 10 innings.

“We had to work hard for everything we got,” Collins said. “And to make it stand up was a struggle. But we’ll take it and get out of here.”

Michael Conforto’s game-tying homer in the eighth inning breathed new life into the Mets. And with the bases loaded in the 10th, Wilmer Flores blooped in the go-ahead run. With that, the Mets snapped a nine-game skid to the Pirates and narrowly avoided a three-game sweep.

But those heroics were only necessary because the Pirates spent much of the evening threatening to hang a debilitating loss on the Mets.

Noah Syndergaard lacked the late life on his fastball and struggled to last six innings. Neil Walker committed a pair of errors that led to three runs. And Jeurys Familia walked a tightrope in the 10th, walking three batters before nailing down the save.

But in the end, the Mets emerged with perhaps their most hard-fought victory of the season.

“The postgame celebration was loud,” Syndergaard said. “It was just one of those wins that reminds you that you love playing for this team.”

Before the game, Collins reshuffled a lineup that had averaged only 2.8 runs since May 12. For one night anyway, the tinkering worked.

Jameson Taillon, the Pirates’ top pitching prospect, allowed three runs in six innings during his highly-anticipated big- league debut. But he departed with the game tied 3-3 thanks to a sacrifice fly by Conforto and a two-run shot by utillityman Ty Kelly, his first big league homer.

Meanwhile, Syndergaard surrendered more hard contact than he had in any other appearance all year. He found himself trailing 2-0 in the first, partly because Walker let a ball through his legs.

Even when the Mets tied the socre on Kelly’s shot, the Pirates jumped right back in the lead on John Jaso’s RBI double. It was one of five doubles off Syndergaard, the highest of his career.

But it was Syndergaard himself who helped tie the score in the fifth, when he ripped a double and scored on Conforto’s sacrifice fly.

Syndergaard allowed three runs in his six innings, far from his dominant form. But on a night in which the Mets needed every break, the righthander did enough to keep his team within reach.

With the score tied at 3 in the seventh, Walker dropped a relay throw from rightfielder Alejandro De Aza, who had fielded Gregor Polanco’s third double of the game. Andrew McCutchen scored the go-ahead run on the play and Polanco later came around on a sacrifice fly, putting the Pirates ahead 5-3.

But Conforto’s game-tying home run, his first since May 22, gave the Mets a new chance.

“It felt very, very good to tie the game there,” said Conforto, who began the day in a 4-for-40 skid. “It’s tough to get runs against this team. They battle, they scratch and claw.”

But it wasn’t until the 10th that the Mets took their first lead, when Flores fought off an inside fastball to push the winning run across.

“It was a big one,” Flores said. All the things that have been going on, winning this game is huge for us. We stayed right there, we kept pushing, and we got the result.”