Gundogan joined Manchester City from Borussia Dortmund in the summer of 2016 and spent seven seasons at the Etihad Stadium, winning among others five Premier League titles and the UEFA Champions League in the just ended season.
Manchester City's 1-0 win over Inter Milan in the Champions League final earlier this month was his 304th and final appearance for Pep Guardiola's side.
Gundogan's contract expires at the end of this month and he has decided to seek a new challenge in Spain.
The 32-year-old Germany international has agreed to join Xavi Hernandez's side on a two-year contract.
Gundogan told the Manchester City club website: "For me, it has been a total privilege and pleasure to be part of Manchester City for the last seven years.
"Manchester has been my home and I have felt part of a very special family at City.
"I have been lucky to have experienced so many unforgettable moments in my time here and to have been captain for this extra special season has been the greatest experience of my career.
"First, I would like to thank Pep. To have been able to play under and learn from him for so long has been something I will never forget.
"I would also like to thank all my team-mates - past and present - who have all played such a special part in making my time here so amazing.
"Finally, I would like to thank the incredible City fans. They have supported me from the moment I arrived, and I owe them all so much for their support.
"This club made me realise all my dreams and I will forever be thankful for this opportunity.
"I will carry City always in my heart. Once a blue, always a blue."
Addressing his decision to join Barca, he added: "If I was going to move, there is only one club in the world that made sense. It was Barcelona or nothing.
"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."