Guardiola’s current contract has just seven months remaining, and is set to expire at the end of the season.
He had insisted he wanted to stay, but speculation had linked him with a move away – with a return to Barcelona even mooted.
However, he has now signed a new contract to keep him at the club until 2023. There were suggestions that City players were disillusioned by the speculation surrounding the boss, who remained coy whenever asked about whether he would stay or go.
He has now been at the Etihad for four years now, and it is now likely that his tenure at City will be the longest time he has spent at a club.
He managed four years at Barcelona before taking a sabbatical year, and left Bayern Munich after just three seasons.
Speaking as the contract was confirmed by the club, Guardiola challenged his players and the club to continue improving. He said: "Ever since I arrived at Manchester City I have been made to feel so welcome in the Club and in the city itself- from the players, the staff, the supporters, the people of Manchester and the Chairman and Owner.
"Since then we have achieved a great deal together, scored goals, won games and trophies, and we are all very proud of that success.
“Having that kind of support is the best thing any manager can have.
"I have everything I could possibly want to do my job well and I am humbled by the confidence the Owner, Chairman, Ferran and Txiki have shown in me to continue for two more years after this season. “The challenge for us is to continue improving and evolving, and I am very excited and about helping Manchester City do that.”
Due to his tendancy to leave jobs after a short period of time, it had been speculated that he would walk away from Manchester at the end of his current deal.
City's ownership group had apparently given Guardiola time to discuss his future with his family, and didn't pressure him to give them a decision either way.
But the fact that he's decided to stay means he has the time to plan for the January transfer window, when they are expected to launch an audacious bid to sign Lionel Messi. Guardiola had been determined to sign his former striker during the previous window, and Messi can agree a pre-contract agreement with City during the January window if he chooses to.
Having already won the Premier League twice already during his time in Manchester, Guardiola's primary focus for the remainder of his contract will be conquering Europe and winning the Champions League.
He and the club have made no secret of their desire to win Europe's premier competition, having come closer than ever last season.
City were beaten 4-1 by Lyon in the quarter-finals of last season's competition, the third time in a row that they've fallen at the last-16 stage.
Having come to the club after winning the Champions League at Barcelona and Bayern, Guardiola will likely turn his attention towards Europe once again.