The Argentine attacker - who joined the Blaugrana in 2000 - originally had a deal that ended in 2016, though an agreement had been struck in December for the 25-year-old to remain at the Liga giants until 2018, and he put pen to paper on that deal on Thursday..
The Camp Nou star will reportedly earn an annual salary of 11 million euros after taxes, and he has a buy-out clause of 250 million euros in his new contract.
Messi has become the third Barca star to extend his stay after Carles Puyol and Xavi, although goalkeeper Victor Valdes had turned down talks in January and revealed he wants his current contract to run its course.
Messi has helped his side to three UEFA Champions League trophies, five La Liga titles and many more pieces of silverware during his time at the Catalan club.
Messi, whose latest extension is his sixth renewal with the Liga leaders, was awarded the Ballon d'Or in January for the fourth consecutive year, beating Real Madrid rival Cristiano Ronaldo and teammate Andres Iniesta.