Ilkay Gundogan ended his trophy-laden seven-year stay with Manchester City by agreeing to join Barcelona on a free transfer on Monday.

The Germany midfielder's last act as a City player — and captain — was to lift the Champions League trophy, which completed a treble of major titles for the English club.

He is heading to Spain on a two-year contract, with the option of a further year, even though Pep Guardiola wanted to keep the 32-year-old Gundogan — the first signing by the City manager after he started in 2016.

CLICK HERE FOR MORE SPORTS COVERAGE ON FOXNEWS.COM

Ilkay Gundogan hoists trophy

Manchester Citys German midfielder #8 Ilkay Gundogan (C) lifts the European Cup trophy as they celebrate on the podium after winning the UEFA Champions League final football match between Inter Milan and Manchester City at the Ataturk Olympic Stadium in Istanbul, on June 10, 2023.  (FRANCK FIFE/AFP via Getty Images)

"This club made me realize all my dreams and I will forever be thankful for this opportunity," Gundogan said. "I will carry City always in my heart. Once a blue, always a blue."

Having missed out on securing the return of Lionel Messi, Barcelona made the signing of Gundogan a priority to add some experience to a midfield already containing youngsters Pedri González and Gavi Páez, two of its pillars going forward, but no longer including veteran leader Sergi Busquets, who is leaving the club.

Frenkie de Jong also played an important role last season for Barcelona coach Xavi Hernández, despite efforts by the club to sell him in the offseason of 2022.

RILEY GAINES CALLS OUT 'DISINGENUOUS' US SOCCER STARS MEGAN RAPINOE, ALEX MORGAN FOR STANCE ON TRANS ATHLETES

Erling Haaland of Manchester City poses for a photograph with Ilkay Guendogan and Phil Foden and the UEFA Champions League Trophy on the Open-Top Bus during the Manchester City trophy parade on June 12, 2023 in Manchester, England. 

Erling Haaland of Manchester City poses for a photograph with Ilkay Guendogan and Phil Foden and the UEFA Champions League Trophy on the Open-Top Bus during the Manchester City trophy parade on June 12, 2023 in Manchester, England.  (Tom Flathers/Manchester City FC via Getty Images)

Barcelona has set Gundogan's buyout clause at 400 million euros (about $435 million).

In a statement, the Spanish champions described their latest signing as a player "who reads the game to perfection" and "one of the world’s best midfielders of the last decade or so."

Gundogan's arrival comes while debt-ridden Barcelona is still struggling to meet the Spanish league's financial rules. Only recently was it able to find a way to officially register Gavi as a first-team player. It is widely expected that the club will need to sell players to reduce its expenses, and the addition of Gundogan will only add to that burden unless compensated by exits.

SPIDER BITE LANDS INTER MIAMI GOALIE IN HOSPITAL, WIFE SAYS

Ederson and Ilkay Gundogan hoist cup

Ederson and Ilkay Guendogan of Manchester City present the UEFA Champions League Trophy to the fans on stage in St Peters Square during the Manchester City trophy parade on June 12, 2023 in Manchester, England.  (Alex Livesey/Getty Images)

While Barcelona sold off part of its future television revenues and other assets to have the cash necessary to sign Robert Lewandowski and others last year, its financial problems have increasingly forced the club to find free agents who want to come to Spain. Last year, the team picked up current players Andreas Christensen, Marcos Alonso and Franck Kessie on free transfers, while other free agents like Memphis Depay have come and gone in recent years.

City was reportedly offering Gundogan only a one-year deal, whereas he wanted a longer contract for some security for his family.

He will go down as a City great, not just for being the captain in its greatest ever season but because of some of his crucial goals and performances from in the midfield, where he could play box-to-box, as an anchorman or — in his favored role — as a player supporting the striker.

No goals were more important than his two to complete City's late comeback from 2-0 down against Aston Villa on the final day of the 2021-22 season, winning the team another league title.

CLICK HERE TO GET THE FOX NEWS APP

Ilkay Gundogan of Germany during the Friendly Interland match between Germany and Colombia at the Veltins-Arena on June 20, 2023 in Gelsenkirchen, Germany. AP | Dutch Height | BART STOUTJESDYK 

Ilkay Gundogan of Germany during the Friendly Interland match between Germany and Colombia at the Veltins-Arena on June 20, 2023 in Gelsenkirchen, Germany. AP | Dutch Height | BART STOUTJESDYK  (ANP via Getty Images)

After joining from Borussia Dortmund, where he was a Bundesliga champion in 2012, Gundogan won five Premier League titles, two FA Cups, four English League Cups and the Champions League with City.

"He has played a huge part in the successes we have enjoyed in recent seasons and Ilkay’s intelligence, leadership and commitment to the club — both on and off the field — has been an inspiration to everyone," City director of football Txiki Begiristain said.

Gundogan arrives at a club that won the Spanish league title last season but failed for a second straight campaign to move past the group phase of the Champions League.