With just minutes left at Villa Park, Mikel Arteta’s side were in danger of stumbling again in their bid to win the title for the first time since 2004.
Arsenal had twice trailed to goals from Ollie Watkins and Philippe Coutinho, only for Bukayo Saka and then Oleksandr Zinchenko to haul them level.
A draw would have taken Arsenal above Manchester City but hardly enhanced their hopes of holding off the champions in a thrilling title race.
But they received a helping hand from their former keeper as Martinez inadvertantly deflected Jorginho’s shot into his own net after it hit the bar in stoppage-time.
Gabriel Martinelli capped Arsenal’s remarkable escape with a goal in the final seconds to lift the north Londoners three points clear of second placed City.
Pep Guardiola’s men would go back above Arsenal on goal difference if they win at Nottingham Forest later on Saturday.
For the first time since August 20, the Gunners were not starting a round of fixtures on top of the Premier League table after losing 3-1 to City on Wednesday.
Arsenal were without a win in their previous three top-flight games and last four in all competitions, but this spirited victory will give them renewed belief they can pip City to the title.
Tom Hanks, a self-confessed Villa fan, was watching from the stands and Arsenal scripted a Hollywood ending in front of the superstar actor
Arteta had bemoaned the “very difficult” fixture schedule that saw Arsenal back in action just 63 hours after the final whistle in their defeat against City on Wednesday.
And Arteta’s fears about Arsenal struggling to cope with the quick turnaround came true after just five minutes.
– Arsenal dig deep –
Caught with too many players pushed upfield, Arsenal were exposed by Matt Cash’s superb lofted pass towards Watkins, who showed nimble footwork to skip past William Saliba before drilling a fine finish into the bottom corner.
Arsenal hit back with a 16th minute equaliser when Mings could only clear Ben White’s cross as far as Saka and the England forward smashed a ferocious strike past Martinez from 12 yards.
Coutinho restored Villa’s lead in the 31st minute.
Alex Moreno got behind White down the right flank and crossed towards Emiliano Buendia, whose clever dummy wrong-footed the Arsenal defence as Coutinho applied the finishing touch with a clinical strike from just inside the area.
Arteta’s men had to dig deep after Coutinho’s first goal this season and they were up to the task.
Zinchenko put Arsenal back on level terms in the 61st minute, drilling a blistering strike past Martinez from the edge of the area for his first Gunners goal since signing from Manchester City.
Leon Bailey almost won it for Villa in the closing stages when his stinging strike was pushed onto the bar by Aaron Ramsdale.
But Arsenal held their nerve and snatched the points in an astonishing finale.
In stoppage-time, Jorginho’s first-time effort from the edge of the area hit the bar, bounced down and struck Martinez on the head before rebounding into the net.
Martinez was crestfallen and the Argentine World Cup winner was involved again when the Gunners wrapped up the points with virtually the last kick.
Martinez went up for a Villa corner but when Arsenal cleared Martinelli was able to run half the length of the pitch before slotting into the empty net as Arteta and his staff celebrated wildly on the touchline.
AFP