The former Barcelona and Bayern Munich boss, 51, has won nine major trophies, including four Premier League titles, since taking charge at City in 2016.
Guardiola said in a statement from the club: "I am so pleased to be staying at Manchester City for another two years.
"I can't say thank you enough to everyone at the club for trusting me. I am happy and comfortable, and I have everything I need to do my job as best as possible.
"I know the next chapter of this club will be amazing for the next decade. It happened over the last 10 years, and it will happen in the next 10 years because this club is so stable.
"From day one I felt something special being here. I cannot be in a better place.
"I still have the feeling there is more we can achieve together and that is why I want to stay and continue fighting for trophies."
City chairman Khaldoon Al Mubarak said: "I am delighted that Pep's journey with Manchester City Football Club will continue.
"He has already contributed so much to the success and fabric of this organisation, and it's exciting to think what might be possible given the energy, hunger and ambition that he clearly still has.
"Under his very special leadership our first team has accomplished so much, whilst continuously playing, and constantly evolving, a City style of football that is admired the world over. Like every City fan, I am looking forward to what lies ahead."