Gundogan, 32, is out of contract with City at the end of the month and has agreed to join Barca on a two-year deal with the option for a third year, the Spanish champions confirmed. His release clause has been fixed at €400 million.
Sources told ESPN last week that City were unwilling to match Barca's financial offer and would only extend Gundogan's contract for one year with an option for a second.
"Today is bittersweet. Goodbyes are never easy, but it's even harder with this team," Gundogan wrote in the Players Tribune.
"When I had to break the news to the boys that I was leaving in our group chat, I was very emotional. I will miss all of them, honestly. But I am happy to say that I'm leaving here as a champion, and I have nothing but love for the club in my heart. How many footballers can say goodbye as the captain of a treble team?
"It's amazing what we achieved. Five Premier League titles in my seven years here. Two FA Cups. The Champions League. The treble. But those are just trophies. The thing that I will remember the most is the feeling inside the squad, especially this season. I've never experienced something like it in football."
The German international becomes the Catalan club's first signing of the summer, although ESPN have previously revealed there is also an agreement in place to sign defender Inigo Martinez when his deal with Athletic Bilbao expires at the end of June.
Barca coach Xavi Hernandez has been keen to strengthen his side in the final third after judging performance levels to have dropped when they were without Pedri last season.
However, with the departure of Sergio Busquets to Inter Miami, Xavi has said the club also desperately need to sign a deeper midfield, with sources telling ESPN that is now the club's top transfer priority.
Gundogan is calling time on a seven-year spell at City after captaining the English side to a historic treble, culminating in their first Champions League trophy earlier this month.
"If I was going to move, there is only one club in the world that made sense. It was Barcelona or nothing," Gundogan added.
"Ever since I was a little kid, I dreamed of wearing that shirt some day. I am confident that I have a few more years left at the highest level, and I just want to help bring Barcelona back to where they deserve to be.
"It will be a reunion with my old friend Lewa, and I'm excited to play under another manager who I have admired for a long time. When Xavi and I talked about the project, it just seemed so natural. I see so many similarities between us as characters and in the way we see the game."