The two-time world champion's previous contract had been due to run out at the end of 2015, and the protracted negotiations became a major talking point during recent races. On Wednesday in Monaco, however, the two parties ended speculation about the Briton's future.
"Mercedes is my home and I couldn’t be happier to be staying here for another three years," Hamilton said. "This is a company filled with real passionate racers, from the board room to the factory floor, and an incredible hunger to win.
"Even after the success of last year, that hunger is greater than ever - and it’s the same for me, too. The Mercedes car I am driving right now is the best I have ever had in my career; it’s just so much fun to be out there every weekend, on the limit and fighting to win at every track. Mercedes-Benz began supporting me in 1998 so I am very proud that this contract means I will mark 20 years with Mercedes in 2018."
Toto Wolff, head of Mercedes-Benz motorsport, said it had been important not to rush negotiations.
"Continuity is one of the key factors for delivering success in Formula One and we now have that in place," he said. "Lewis enjoyed an historic world championship season with Mercedes-Benz last year and it was a priority for this season to renew his contract for the next term.
"We have taken the right amount of time with the process and not rushed ourselves. The result is a strong agreement that will enhance Lewis’ association with the Mercedes-Benz brand, and that recognises and respects the market value of Lewis and of Mercedes in Formula One. Lewis’ sporting track record speaks for itself and he is a great personality for the company.
"Personally, I am looking forward to continuing to race with the strongest driver pairing in Formula One and to more historic achievements together.”
Hamilton joined Mercedes ahead of the 2013 season, having spent the entirety of his F1 career up to that point with McLaren. He won once in his debut season, before prevailing in a tense title-fight with team mate Nico Rosberg as the Silver Arrows dominated in 2014. The German agreed his own multi-year extension with Mercedes in July last year.
Hamilton leads Rosberg by 20 points after the first five races of 2015.