The reigning world champion, 24, will see out his contract with Renault before replacing Kimi Raikkonen or Juan Pablo Montoya.
Alonso said: "To become part of a team with such a desire to succeed and passion for performance is a dream come true for any Formula One driver.
"I'm very excited about 2007 and the fantastic opportunity to drive for McLaren.
"It will be a new beginning for me and a tremendous challenge.
"Obviously I will be sad to leave Renault but sometimes possibilities come along which are just too good to miss.
"I'm pleased that we are able to make this announcement now as it will allow my current team and I to focus 100 per cent on defending the world championships next year."
McLaren boss Ron Dennis added: "It's great that our strong belief in the strength and competitiveness of the Vodafone McLaren Mercedes package has been further endorsed by the world champion."