Guardiola will replace Manuel Pellegrini, who said he would be leaving the club at the end of the season.City said in a statement that negotiations with Guardiola "were a re-commencement of discussions that were curtailed in 2012."
"Out of respect for Manuel Pellegrini and the players, the club wishes to make its decision public to remove the unnecessary burden of speculation," City said.
"Manuel, who is fully supportive of the decision to make this communication, is entirely focused on achieving his targets for the season ahead and retains the respect and commitment of all involved with the leadership of the club."
Guardiola is widely regarded as the one of the best managers in Europe. He won 14 trophies at Barcelona from 2008-12, and has coached Bayern Munich since 2013.
Guardiola led Bayern to the Club World Cup and UEFA Super Cup that same year, a German league and cup double in 2014, and another Bundesliga title in 2015.
Guardiola said in December he would be leaving Bayern Munich at the end of this season, and said in January his next job would be in the Premier League.
City has been heavily linked with Guardiola over the last two seasons. Two City executives — Ferran Soriano and Txiki Beguiristain — worked with Guardiola at Barcelona.
Pellegrini has been City manager since 2013, winning the Premier League and League Cup in his first season in charge. He signed a new deal with City last offseason to keep him at the club until 2017.
City is in contention for four trophies this season.