The 45-year-old, currently in charge at Bayern Munich, will replace Manuel Pellegrini, who will leave on 30 June.
A statement from City said Chilean Pellegrini, 62, was “fully supportive” of the announcement being made.
The club said negotiations with former Barcelona coach Guardiola had been “a recommencement of discussions that were curtailed in 2012”.
Roberto Mancini was City boss at the time, and led them to the domestic title that year.
Pellegrini succeeded the Italian in 2013 and took the club to a Premier League and League Cup double the following season.
He has won 64 of his 99 Premier League games as a manager, a record only eclipsed by Jose Mourinho, who won 73 of his opening 99 league matches as Chelsea boss.
City could yet win four trophies under Pellegrini this season.
They are already through to the final of the League Cup and are second in the league behind Leicester City.
The Blues are also through to the knockout stages of the Champions League and will play Chelsea in the fifth round of the FA Cup.
“I talked to the club and I will finish my contract on the original date,” said Pellegrini on Monday.
“We signed a contract for one more year, but with a clause that one of the club or me cannot use that extended contract. So I will finish here on the original date.
“They are not doing anything behind me. I knew this a month ago. But I don’t think it’s good, this rumour and speculation about different things. I would prefer to finish the speculation today. That’s why I told the press, I told the players, and I spoke with the club two weeks ago saying that I would do it.”