Sterling had been in negotiations with City for several months and the England winger has finally agreed the bumper new deal after being linked with a move to Real Madrid.
The 23-year-old is now tied to City until 2023, with reports earlier this month claiming his extended contract would be worth £300,000 ($389,000) per week, making him England's best paid player.
"I'm delighted to sign. My development here has been incredible," Sterling told City's website.
"I felt from the minute I got here it was the right choice for me. It's really paid off for me and I'm really grateful."
Sterling has blossomed under City manager Pep Guardiola and has developed into a key player for club and country since arriving from Liverpool in 2015.
He scored 23 goals in all competitions last term as City won the Premier League title in record-breaking style and also lifted the League Cup.
Sterling has netted seven goals in the opening three months of the current season, helping City back to the top of the Premier League.
"Every season you come in you want to do better than your previous season. You want to try and develop and get better," he said.
"With the facilities we've got here there's no reason not to. With the coaching staff and the players we have in this team it's the perfect environment to develop and get better."
Sterling's contract decision comes on the eve of Sunday's derby against arch rivals Manchester United.
City go into the clash in fine form after scoring a total of 12 goals in their last two matches against Southampton and Shakhtar Donetsk.
Sterling bagged three of those goals, while also winning a controversial penalty against Shakhtar that he later admitted shouldn't have been given.
City's director of Football Txiki Begiristain added: "This is a significant moment for the club. Raheem has improved dramatically in the past two seasons and is now one of the Premier League's best attacking players. His statistics tell their own story.
"He's quick, strong and excellent in front of goal -– everything a modern-day forward needs to excel.
"We're all delighted he has committed his future to City."