MADRID (AP) - Lionel Messi's time at Barcelona appears to be over.

Barcelona announced Thursday that Messi will not stay with the club, saying that the Spanish league's financial regulations made it impossible to sign the Argentina star to a new contract.

He is leaving after 17 successful seasons in which he propelled the Catalan club to glory, helping it win numerous domestic and international titles since debuting as a teenager.

Barcelona said in a statement that a deal for a new contract had been reached but financial “obstacles” made it impossible for the player to remain with the club.

“Despite club and player reaching an agreement and their clear intention to sign a new contract today, this cannot happen because of financial and structural obstacles,” the club said.

It blamed “Spanish league regulations” for not allowing the club to sign a new contract with the player. His previous one had ended on June 30.

“As a result of this situation, Messi shall not be staying on at FC Barcelona,” it said. “Both parties deeply regret that the wishes of the player and the club will ultimately not be fulfilled.

“FC Barcelona wholeheartedly expresses its gratitude to the player for his contribution to the aggrandizement of the club and wishes him all the very best for the future in his personal and professional life,” the statement said.

Messi had asked to leave Barcelona for free at the end of last season but had his request denied by then-president Josep Bartomeu. Joan Laporta took over the presidency and appeared to have convinced Messi to stay. But Laporta had said recently that the club was struggling to fit the player's salary - even with hefty reductions accepted by the player - into the league-controlled salary cap.

In Messi's previous contract, signed in 2017, he reportedly earned 138 million euros ($163 million) per season.

The league had announcement on Wednesday that it secured $3.2 billion in private equity funding to help the clubs, which appeared to pave the way for Barcelona to re-sign the Argentina star. But the deal with Messi fell through after club officials met with the player's representatives in Barcelona on Thursday. Some local reports said it was Messi who had changed his mind about staying, while others said it was the club that got upset with new demands made by the player's staff.

Barcelona was one of the clubs hardest hit by the coronavirus pandemic. The league slashed its salary cap last season and the club had been trying to clear cap space by releasing some of its players. It had only signed free agents this summer - including Memphis Depay, Sergio Aguero and Eric Garcia - to avoid paying transfer fees.

The league has worked hard over the years to create stability through strict economic control that kept clubs from going into heavy debt. President Javier Tebas had said earlier that the league would not take a huge hit by losing a player like Messi, noting that it continued to thrive after Cristiano Ronaldo left Real Madrid to Juventus a few years ago.

It was unclear whether Messi was already in talks with other clubs, but he has previously been linked with cash-rich Manchester City and Paris Saint-Germain.

The Argentine made no immediate public statement. Club president Laporta was going to address the media on Friday.

Barcelona removed Messi from its squad list on the club's website shortly after the announcement, and posted a video on its Twitter accounts thanking the player.

Messi will be leaving after having won 35 titles. He helped the club win the Champions League four times, the Spanish league 10 times, the Copa del Rey seven times and the Spanish Super Cup eight times.

While with the club, Messi earned himself a record six Ballon d'Or awards as the world's top player. He is the team's all-time scorer with 672 goals in 778 appearances, and the top scorer in the Spanish league with 474 goals in 520 matches. He also is the player with most matches with the club.

He was the top scorer in the Spanish league in eight seasons, and the top scorer in the Champions League on six occasions. His 26 goals against Real Madrid are a record for the “clasico” matches against Barcelona's fiercest rival.

Messi arrived at Barcelona at age 13, when he and his family came to Spain to try his luck at Barcelona's youth academy. He made his official debut on Oct. 16, 2004, and two years later helped the club win its first Champions League in a squad led by Ronaldinho.

Associated Press writer Joseph Wilson contributed from Barcelona.