TAMPA, Fla. — Jonathon Niese may be returning to New York after all.

Just not as a member of the Mets.

advertisement | advertise on newsday

Niese, who played the first eight seasons of his big-league career with the Mets — and the latter part of 2016 with them after the Pirates traded him back to Flushing — agreed to a minor-league deal with the Yankees on Sunday.

The deal is contingent on the 30-year-old lefthander, who has spent the vast majority of his career as a starter, passing a physical.

Niese, taken by the Mets in the seventh round of the 2005 draft, is 69-68 with a 4.07 ERA in nine seasons. He has appeared in 197 games as a starter and 14 as a reliever.

The Yankees, who spent the offseason looking to bolster their pitching staff, see Niese as potential help for either role. They were interested in acquiring a second lefthanded setup man, to go along with Tommy Layne, for the bullpen but did not find anyone who fit their budget.

Niese was traded to the Pirates in December 2015 for second baseman Neil Walker, a deal that turned out overwhelmingly in the Mets’ favor. The Pirates dealt him back to the Mets at the 2016 trade deadline in exchange for Antonio Bastardo.He was granted free agency Nov. 3 when the Mets declined his club option.