Steven Matz of the New York Mets walks to the...

Steven Matz of the New York Mets walks to the dugout during the fourth inning after he was removed from a game against the New York Yankees. Aug. 17, 2017. Credit: Jim McIsaac

Steven Matz had successful surgery to reposition the irritated ulnar nerve in his left elbow on Wednesday, according to a source.

The Mets lefthander from East Setauket had been pitching through pain for a while, he said Monday.

An exam by team physician David Altchek on Monday revealed that a problem with Matz’s ulnar nerve had caused the persistent pain and led to season-ending surgery.

Matz (2-7) hadn’t won since June 28 and saw his ERA spike to 6.08 — the highest of his career — in 66 2⁄3 innings.

SUBSCRIBE

Unlimited Digital AccessOnly 25¢for 6 months

ACT NOWSALE ENDS SOON | CANCEL ANYTIME