This ended speculation that the five-times World Player of the Year could leave the club he has spent his entire career for free next June.
“FC Barcelona and Lionel Messi signed on Saturday morning a new contract that will keep the Argentine superstar at the club through the 2020/21 season,” said a statement from Barca, posting a picture of Messi signing the deal alongside club president Josep Maria Bartomeu.
“The buyout clause was set at 700 million euros (626.25 million pounds).”
Messi agreed the new contract with FC Barcelona in July but the club did not release the usual photo of the player putting pen to paper.
This had fuelled speculation he could depart in June 2018, when his previous deal ran out, for free.
Messi leads the scoring charts in La Liga with 12 goals and on Friday picked up the 2017 European Sports Media Golden Shoe.
It was for being the top scorer in a domestic league last season with 37 goals.
Barca can extend their lead at the top of La Liga to seven points if they beat second-placed Valencia on Sunday.(Reuters/NAN)