The double world champion, who turned 41 on Friday and was coming to the end of his contract with French team Alpine, will replace German driver Sebastian Vettel, a four-time champion, who last week announced his retirement from Formula One at the end of the current season.
Alonso, who won his world titles with Renault in 2005 and 2006, said the Aston Martin team -- which is owned by Canadian billionaire Lawrence Stroll whose son Lance drives the other car -- "is clearly applying the energy and commitment to win" and is "one of the most exciting teams in Formula One today".
"I have known Lawrence and Lance for many years and it is very obvious that they have the ambition and passion to succeed in Formula One," said Alonso who came eighth in Sunday's Hungarian Grand Prix and is currently 10th in the world championship standings.
The Spaniard made his F1 debut in 2001. After winning his world titles with Renault -- the precursor to Alpine -- he failed to add any more in two spells with McLaren and during a five-year stint with Ferrari.
In 2018, he left the sport to try his hand at other forms of racing, winning the Le Mans 24 Hours twice and taking part in the Indianapolis 500 and the Dakar Rally.
Alonso returned to Formula One with Alpine in 2021, clinching his 98th and most recent podium at that year's Qatar GP. His last victory came at his home Grand Prix in Barcelona in 2013, but he is eager to add to his 32 race wins.
"I still have the hunger and ambition to fight to be at the front, and I want to be part of an organisation that is committed to learn, develop and succeed," Alonso said.
"I intend to win again in this sport and therefore I have to take the opportunities that feel right to me."
Vettel, who scored 53 GP wins and won four successive championships with Red Bull from 2010 to 2013, had tipped his friend and protege Mick Schumacher, son of the legendary Michael Schumacher, to be his successor.
However, the British-based team which is still developing since Stroll took it over in 2020, have turned instead to the wealth of experience that Alonso can offer.
"The whole company is very excited to bring Fernando's incredible experience and brilliant pace and racecraft to the team," Aston Martin said in a statement.
"The recruitment of a special talent such as Fernando is a clear statement of intent from an organisation that has committed to developing a winning Formula One team."