A renewal was agreed between player and club in July but it is only now that Messi has put pen to paper on the contract.
Announcing the deal, the LaLiga club added that the Argentina forward has had a £626million buy-out clause inserted into his contract.
That means, in all likelihood, the 30-year-old will finish his career at the Nou Camp and not, as has been reported for some time, move to Manchester City.
Messi, who made his senior debut as a 16-year-old in a friendly against Porto, has eight LaLiga titles, four Champions League wins and five Copa del Rey successes among his list of honours with the Catalan giants.
He is regarded by some as the greatest player of all time and the signing of his new deal means his Barca dynasty can continue apace.
Messi arrived at Barca from Newell’s Old Boys as a teenager in 2000 and made his first competitive appearance against Espanyol as a 17-year-old.
He scored the first of his club record 523 goals - they have come in just 602 matches - against Albacete in May 2005 and has since claimed the Ballon d’Or on five occasions, more than any other player.
On Friday, he was presented with his fourth Golden Shoe award for the top scorer in Europe, while his 30 titles put him alongside team-mate Andres Iniesta as the most in club history.
Messi’s career in numbers:
523 - goals for Barcelona, in 602 games, including a record 361 in LaLiga.
91 - goals scored in 2012, breaking the calendar-year record set by German Gerd Muller in 1972.
40 - career hat-tricks; 36 for Barcelona, four for Argentina.
0.87 - Goals-per-game average for Barcelona.
123 - caps for Argentina.
61 - goals for Argentina, taking him past Gabriel Batistuta as his nation’s all-time leading scorer. That tally includes his two in the 2008 Olympics.
4 - goal tally in eight Argentina vs Brazil matches in his career.
8 - LaLiga titles with Barcelona.
4 - Champions League wins.
5 - times he has won the Ballon d’Or, as the world’s best player (in 2009, 2010, 2011, 2012 and 2015).
2 - Messi and Cristiano Ronaldo are the only players to have won more than three Ballon d’Or awards.
29 - trophies won with Barca.
2008 - Olympic gold in Beijing is Messi’s only major honour with Argentina.
47 - seconds into his Argentina debut before he was sent off, against Hungary in 2005, aged 18, after coming on as a substitute.
67 - Messi’s height in inches (5ft 7in).
16 - Age at which Messi made his Barcelona first-team debut.
22 - How old Messi was when he picked up his first Ballon d’Or award in 2009.
10 - shirt number with which Messi has become synonymous for club and country.