Former Arsenal boss Emery, who had been in charge of Spanish club Villarreal, will take over at Villa on 1 November.
Villa have paid a £5.2m buyout fee to Villarreal for the 50-year-old.
Caretaker Aaron Danks will again take charge at Newcastle this weekend, after Gerrard was dismissed last week following a 3-0 Premier League defeat by Fulham.
Emery, who would have been out of contract at Villarreal next summer, will begin work next week “after his work permit formalities are completed,” Villa said.
The club added: “Aston Villa is delighted to announce the appointment of Unai Emery as the club’s new head coach.
“A highly experienced top level coach who has managed over 900 games, Unai has also previously managed in the Premier League during a spell with Arsenal, leading the Gunners to a Europa League final.
“He has also enjoyed notable success at Sevilla and at Paris St-Germain. In Seville, he won three successive Europa League titles between 2013 and 2016 before going on to lift a Ligue 1 championship in France as well as two French Cups, two French League Cups and two Trophee des Champions.”
Emery joined Villarreal in 2020 and led them to Europa League success in the 2020-21 season, beating Manchester United in the final.
The Spanish club also reached last year’s Champions League semi-finals under Emery, losing 5-2 to Liverpool on aggregate.
Emery’s Villarreal appointment followed his sacking after just 18 months as Arsenal manager in November 2019, after failing to win in seven games – the Gunners’ worst run at the time since February 1992.
During his time in north London he took Arsenal to the Europa League final, losing to Chelsea in 2019.
Villa beat Brentford 4-0 on Sunday under caretaker Danks – just their third win in 12 Premier League games this season – which left them 14th, three points above the relegation zone.
The club had also held talks with representatives of Sporting Lisbon coach Ruben Amorin.