The four-time Ballon d'Or winner agreed to terms for the deal in December, but has presumably been so busy scoring goals and being brilliant that he's only now found the time to sign it.
Read a statement at Barcelona's official website:
This afternoon Leo Messi extended his contract with FC Barcelona through June 30 of 2018. The signing ceremony was attended by the player, President Sandro Rosell, Vice-President Josep Maria Bartomeu and the Director of Football Andoni Zubizarreta.
To celebrate Messi's new deal, which will see him earn $14.75 million a year net and includes a buyout clause of $335 million (CNN), Barcelona released the above video on YouTube.