Guardiola has been at Manchester City since 2016, winning four Premier League titles, four League Cups and one FA Cup.
The 51-year-old would have seen his previous contract expire at the end of this season, causing concern among some of the club's fans.
But Man City fans can now rest easy as Guardiola attempts to add the Champions League to his list of laurels in England.
The Premier League champions lost last year's final to Chelsea and will face RB Leipzig in the round of 16 stage of this season's competition.
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 added: "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."