The Italy midfielder will join Frank Lampard and David Villa at New York, currently competing in their first Major League Soccer season.
Pirlo leaves Juve after four years and four straight Serie A titles, and his final appearance for the club was in last month’s Champions League final defeat to Barcelona.
A New York City statement confirmed he will join his new team-mates on July 21 and will be immediately available for selection.
Pirlo said: “I have been wanting this experience for a long time and now that the opportunity materialised I wanted to take it. This is a club on the rise and shares my same hunger to achieve important results in the League. I am hoping to win.
“I had several opportunities to play outside of Italy, but I never had a doubt in picking New York for the enthusiasm of the people that come and watch the team.”
Coach Jason Kreis said: “Nobody could question that in Pirlo we are bringing one of the best in the world and one of the finest players to come to MLS.”
Juve posted a farewell message to the 36-year-old on their website, confirming his contract had been mutually terminated.
The statement went on: “We like to think of this as more of a handshake, a pat on the back from friends who have shared amazing experiences.”