Alonso finished eighth at the Hungarian Grand Prix on Sunday
The 41-year-old Spaniard, who has raced for Alpine since 2021, will replace Sebastian Vettel following the German's retirement at the end of the season.
Alonso, F1 champion in 2005 and 2006, returned to the sport in 2021 after a two-year hiatus racing elsewhere.
"I still have the hunger and ambition to fight to be at the front," Alonso said.
"Aston Martin is clearly applying the energy and commitment to win and it is therefore one of the most exciting teams in F1 today.
"No-one in F1 today is demonstrating a greater vision and absolute commitment to winning, and that makes it a really exciting opportunity for me.
"I want to be part of an organisation that is committed to learn, develop and succeed.
"We all appreciate that there is much to be done to get to the front, and that we must apply all our energies in working together to find performance.
"I intend to win again in this sport and therefore I have to take the opportunities that feel right to me."
The move has come as a surprise within F1 - and is a blow to Alpine, where Alonso has been outperforming team-mate Estasban Ocon this season, although he is behind the Frenchman in the championship as a result of a series of reliability problems.
Alpine chief executive officer Laurent Rossi said at the French Grand Prix 10 days ago that the team were "discussing with [Alonso]; we are building scenarios for him".
Rossi added: "Fernando is a legend of the sport, but also a legend of the Renault group. For us, he is the champion."
In a statement Alpine said: "Fernando has always been, and always will be, part of the Renault and Alpine family and we're proud and privileged to have shared so many on-track moments together."
The word in F1 is that there had been a hitch in negotiations between Alpine and Alonso over the length of his contract, with the driver wanting a firm two-year deal and the team preferring an option clause after next season.
Aston Martin wanted Vettel to stay and had offered him a contract for next season, but they had also had informal exploratory chats with Alonso in case the four-time champion wanted to stop.
When Vettel made his decision, Aston Martin moved quickly.
The likelihood is that Alonso has signed a two- or three-year deal with options after each year that give him more certainty than he was being offered by Alpine.
On the face of it, the move is a backwards step in terms of performance for Alonso, as Alpine are well ahead of Aston Martin this season.
But Alonso's self-confidence will assure him that he can add significant performance to the car, and he has noted the string of senior hires the team have made in recent times, including recruiting former Red Bull head of aerodynamics Dan Fallows as technical director.
Next year's car will have Fallows' fingerprints on it as he joined the team earlier this year, in time to feed into development.
Aston are also building a state-of-the-art new factory at their Silverstone base. The design and race team will move into the first stage of it by the spring of next year, before two further buildings, including a wind tunnel, come on stream later.
Aston Martin team owner and executive chairman Lawrence Stroll said: "I have set out to bring together the best people and develop the right resources and organisation to succeed in this highly competitive sport, and those plans are now taking shape at Silverstone.
"It seemed natural therefore to invite Fernando to be part of the development of a winning team, and we very quickly established in our recent conversations that we have the same ambitions and values, and it was logical and easy to confirm our desire to work together."
Team principal Mike Krack said: "I have witnessed the excitement in the engineering team and throughout the whole organisation at the opportunity to work with Fernando. We know that nearly everyone can learn from someone of Fernando's calibre and experience. We are confident that he will inspire everyone to lift their game.
"We are on a journey to create a winning organisation, and it is clear that Fernando will accelerate our progress and bring us to a performance in which we can take pride."
Alonso's team-mate in 2023 will be Stroll's son Lance.
-- Courtesy of BBC Sport