Lionel Messi will be 34 by the time his next Barcelona contract is up. (Daniel Ochoa de Olza/AP file)

Barcelona announced Wednesday that megastar Lionel Messi will sign a three-year contract extension with the Spanish soccer titan, agreeing to remain at Camp Nou through the 2020-21 season. He still had one year remaining on his existing contract, but both sides wanted to ensure that the 30-year-old forward would remain with Barcelona for the remainder of his productive professional career.

“The Club is very happy with both the renewal and the commitment of Messi, the best player in history, who has played his full professional career at Barça and has led the team to an era of extraordinary success, the likes of which has never been seen in world football,” the team said in a statement.

According to Kaveh Solhekol of Sky Sports, Messi will be making somewhere around $646,000 per week, or close to $33.6 million per year.

Messi has been with Barcelona since leaving his native Argentina at age 13 and played his first game with its senior team in 2004. He has since gone on to nearly unsurpassed success, with a club-record 507 goals in 583 games, four Champions League trophies, eight Spanish league titles and five Copa del Rey championships. But there is some risk to the deal, which reportedly contains a buyout clause worth 300 million euros: Messi will be 34 when his contract runs out, and Barcelona was eclipsed by Real Madrid last season in La Liga play and fell in the Champions League quarterfinals for the second straight year. The team doubled down on its stars, however, agreeing to new deals with Neymar, Luis Suarez and now Messi.

“Maintaining the method, that’s the key,” Manchester City Coach Pep Guardiola, Barcelona’s manager from 2008 to 2012, told L’Esportiu when asked what the team needed to do to remain at the top of European club soccer. “I said that when I was here and we were winning. A day will come when lose and there will be doubts about the method. And those that are in charge will decide [what to do].”

Luis Enrique stepped down as Barcelona’s coach after last season, replaced by Athletic Bilbao’s Ernesto Valverde.

“Everyone can be relaxed [with Valverde’s appointment],” Guardiola said. “I think Barcelona need a coach like Ernesto. A squad like the one they have, which has won everything, needs a guy who wants them.”