New York: To avoid the embarrassment of a winless homestand, the slumping New York Mets needed to beat the top team in baseball with their best pitcher on the mound.

That’s exactly what they did.

Seth Lugo tossed six dominant innings in a stellar spot start, Todd Frazier hit a two-run homer and the Mets blanked the New York Yankees 2-0 on Sunday night to snap an eight-game skid.

“This was big-time. We definitely need to turn things around,” Lugo said. “Big game like that in front of a big crowd, hopefully that gives us momentum.”

Frazier connected against Yankees ace Luis Severino, going deep for the second consecutive night to help the Mets prevent a Subway Series sweep at Citi Field. They ended a 10-game home losing streak and averted an 0-9 homestand that would have matched the worst in team history.