The Italy striker, who previously played for Milan's rivals Inter, returns to San Siro on a four-and-a-half-year contract.
City confirmed Balotelli's exit on their website and the 22-year-old, who won the FA Cup and the Premier League in his two full seasons but made many headlines for his disciplinary problems, thanked manager Roberto Mancini for standing by him.
He said: "I love Roberto, he has been very important for my career, and I will always thank him for having trust and faith in me.
"Being at City was an important part of my life and career. I needed to grow up like a player and as a person and it has been a very good experience for me.
"I will remember, too, the song that City fans had for me. It was special for me and I always liked to hear it. I hope they can still sing it sometimes.
"I will always be interested in Manchester City and their fortunes. I really hope that City can win the league again this year and beat United. I think there are great players at the club and a great manager too."
Mancini said: "We are very sorry for him because he leaves the club but we hope Mario can continue to improve and continues to work hard because he is a top, top player."
The player's agent, Mino Raiola, insists the exit of the 22-year-old forward is Italy's gain and England's loss.
"In England they'll regret Balotelli for a long time, Raiola told Sky Sport Italia. "He is an extreme talent. England has only seen 50 per cent of what he can do.
"Balotelli is a cultural asset. We have decreased by 50 per cent the value of the Premier League and improved by 50 per cent the value of Serie A.
"All journalists in England are sad but the important thing is that we have brought a top player back to Italy.
"This negotiation was very difficult. It seemed to fail six or seven times in the last 60 days, especially because of journalists.
"Manchester City's owners were also not convinced they wanted to sell Mario. But we worked step by step.
"Mario's return is a positive sign for all Italian teams. We had to be calm and balanced - and we were. We thank Milan for believing in this deal at a very difficult time economically."