The 25-year-old Messi, a three-time world player of the year, has 90 goals so far in 2012, surpassing Gerd Mueller's 40-year-old record of 85 in a calendar year.
Xavi Hernandez and Carles Puyol also agreed to new deals with the team.
Messi, whose contract was due to expire on June 30, 2016, extended his commitment to the club to June 30, 2018, Barcelona said in a statement.
Puyol and Xavi extended theirs to June 2016.
"This news means that FC Barcelona has secured its ties with three of its most important players," the statement said, adding that the contracts would be signed "over the course of the next few weeks."
Puyol, the 34-year-old captain, had said he wants to continue his professional career until he's 40, although he said he didn't want to "have to drag myself onto the field."
Messi scored his 22nd double of 2012, and his sixth in six games, when Barcelona beat Atletico Madrid 4-1 on Sunday, opening up a nine-point lead over its closest rival in the Spanish league.
Relying on the Argentina forward's uncanny ability to puncture defenses, Barcelona has attained a Spanish-league record start of 15 victories in 16 rounds.
Barcelona was also still in contention in the Champions League and Copa del Rey.