Lionel Messi has agreed to stay at FC Barcelona until 2021 in a deal that all but commits the star striker to playing out the rest of his top-flight career at the Spanish giants.

The megastar who joined Barcelona as a teenager 17 years ago will remain at the club until he is 34 under the new deal, the Catalan club announced Wednesday, ending months of speculation about the future of the five-time Ballon d’Or winner.

“The deal will be signed in the coming weeks, when Messi returns to the team for pre-season training,” the club said in a statement, as the 30-year-old enjoyed his honeymoon just days after he wed his childhood sweetheart in Argentina.

b’Messi joined Barcelona at the age of 13. Reuters.xc2xa0′

Messi has hinted in the past that he would like to return in the future to Argentina to play for his very first club, CA Newell’s Old Boys in his hometown of Rosario, where he wed last week. But he has also said that his priority is to win more honours with Barca, the club he has called his home since he was 13.

No financial details of Messi’s new contact were disclosed, but Spain’s Marca sports daily reported on Tuesday that the deal included a 300-million-euro ($340-million) termination clause.

Under his current contract, due to run out in June 2018, Messi earns around 20 million euros a year in salary, according to Spanish media — and this didn’t include millions of euros in revenues earned from ads and performance-linked bonuses.

Messi joined FC Barcelona in 2000 when he was just 13 years old in the youth training centre.

“He made his first team debut at just 16 years of age in a friendly against FC Porto, before making his debut the following season against Espanyol at 17,” the club said in a statement.

“Shortly after, he scored his first senior goal with a clever lob against Albacete at the Camp Nou.”

The deal announcement is likely to reassure fans and members of FC Barcelona, which has had a disappointing season by the club’s own high standards.

b’Messi recently got married to his childhood girlfriend. Reuters.xc2xa0′

The club was eliminated from the Champions League in the quarter finals by Juventus, and came second behind arch-rivals Real Madrid in La Liga, though Barca did win the Copa del Rey.

Leading scorer

Messi’s contract extension consolidates the much-feared “MSN” striking trio which also includes Brazil’s Neymar and Uruguay’s Luis Suarez.

Both have also renewed their contracts until 2021.

With 507 goals scored in 583 official matches, Messi is the club’s all-time leading scorer and is widely considered the world’s best player along with Portugal captain Cristiano Ronaldo, his Real Madrid rival.

“He’s the best player I’ve ever seen on the pitch,” said Ernesto Valverde, Barcelona’s new coach, of Messi.

Now 30, Messi could have been tempted by other horizons — having been courted by clubs like PSG and Manchester City — particularly as he was found guilty last year of tax fraud in Spain.

But he has lived in Catalonia since his early teens, and currently resides in Barcelona with his now-wife Antonella Roccuzzo, their son Thiago, four, and Mateo, one — both of whom were born in Spain.

And Messi himself said in May that his aim as a footballer was to “try and win the most titles possible” with FC Barcelona.

Feature image: Reuters