Patrick Vieira: “I am leaving New York with some wonderful memories and I will always be a fan of the club.” (Noah K. Murray-USA TODAY Sports)

Patrick Vieira said goodbye to New York City FC and its supporters via a letter on Twitter Monday.

Vieira, who directed the Major League Soccer club for the past 2 1/2 seasons is leaving City to coach Nice in French Ligue 1.

“After two and a half years as head coach of NYCFC, today will be my last day,” Vieira wrote Monday. “I can honestly say that my time with the club has been absolutely perfect — both on the professional and personal level,” he wrote on Twitter. “I love New York, my family loves New York, and I will always have a NYCFC family here.

“I want to thank the amazing fans for all of their support throughout the past few years; your passion and love for the team is what motivates everyone on a daily basis.

“I also want to thank Marty Edelman, Jon Patricof, Claudio Reyna and the entire sporting department — especially Rob Vartughian, Javier Perez and Dan Fradley. NYCFC has incredible players who are very hard working and professional and I’ve enjoyed every single day with them.

“I am leaving New York with some wonderful memories and I will always be a fan of the club.”

Vieira departs the team in good shape. NYCFC (8-3-4, 28 points) is in second place in the Eastern Conference, trailing Atlanta United FC (9-3-3, 30) by two points.

NYCFC will look to name Vieira’s successor over the next two weeks, as the team has off during a World Cup break. City will host Toronto FC at Yankee Stadium Sunday, June 24 at 5 p.m.

Vieira, who was born in Dakar, Senegal, is a legend in France and England. He was a member of the national team that captured the 1998 World Cup in France. He also was an important cog in Arsenal’s great success in the English Premier League from 1996-2005.