The 32-year-old, who will compete at the upcoming World Cup, netted 13 league goals in his only season with Atletico following his move from Barcelona.
“Throughout my career I've always tried to keep pushing myself to achieve new targets and this represents another important goal for me,” Villa told his new club's website.
“I want to try and help MLS continue to grow, through playing, working hard, scoring goals and at the same time try to make New York City FC become the best team in the league.
"It's a real honor that the people who have formed the club have focused their attention on me.
"I'm keen to do the best I can, take on board that extra responsibility and prove my worth by repaying the confidence they have shown in me.”
City's CEO Ferran Soriano added: “This is a historic and exciting moment for the City family and the building of New York City Football Club.
“I know David really well; he is one of the best footballers in the world, a true winner and in an outstanding moment of his career. I’m sure New Yorkers will enjoy watching him play for their city.”
Villa, a star at South Africa 2010, is his country's record scorer, with 56 goals from 94 appearances.