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.

advertisement | advertise on newsday

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.