McGinn, who had the freedom of the Arsenal penalty area, latched on to Anwar El Ghazi’s cross, converting past Leno and into the far corner to give Villa a well-deserved lead.
The Arsenal defenders were left scratching their heads after the opener and the Unai Emery’s side suffered a further setback shortly before half-time as Maitland-Niles, who was booked earlier in the game for bringing down El Ghazi, was sent off after crashing into Neil Taylor to earn a second booking.
It left the Gunners with a mountain to climb after the break as Emery brought on Chambers for Saka in a bid to help shore up his leaking defence.
Arsenal were handed a lifeline when Guendouzi was tripped in the penalty area by Bjorn Engels. Pepe, who has scored 10 penalties since the start of last season, made no mistake from the spot, firing the ball straight down the middle to level things up.
Parity was short-lived though as Villa responded almost immediately. McGinn flashed wide of the target before Jack Grealish burst into the box before squaring for Wesley to sweep home at the near post.
Ten-man Arsenal had it all to do again as Guendouzi’s drive was touched onto the base of the post by Heaton and Aubameyang skied over the bar from close range.
Arsenal handed a full Premier League debut to Bukayo Saka as Unai Emery made six changes from the side that beat Eintracht Frankfurt in the Europa League on Thursday.
Aston Villa made one change from the side that drew 0-0 with West Ham last Monday with Trezeguet replacing Jota, who dropped down to the bench.
But Villa, who were dropping deeper and deeper, continued to invite pressure and the Gunners equalised for a second time as Chambers poked home from close range.
The comeback was complete three minutes later as Engels fouled Aubameyang on the edge of the area, and Arsenal’s talisman, who was wearing the captain’s armband after Granit Xhaka was taken off, fired in his seventh of the season from the free-kick.
A shell-shocked Villa pushed in the closing stages for an equaliser of their own, but Arsenal held out to secure a crucial victory.
Chambers: Massive win for Arsenal
Arsenal defender Calum Chambers: “I am very pleased. I hold my hand up to their second goal, so I had to put things right. We stuck in there and worked hard and deserved it in the end.
“The win is massive for us as a club and team. We have the quality and the spirit. We dug in deep to get the momentum going.”
What the managers said
Arsenal head coach Unai Emery on Maitland-Niles’ second booking: “I was thinking we can manage. He didn’t touch the player. He touched the ball. We had to accept the referee’s decision.”
3:46 Unai Emery was pleased with the spirit his side showed despite being reduced to 10 men in the win against Aston Villa, but admits there is room for improvement tactically
Aston Villa boss Dean Smith: “We will never get a better chance to win at the Emirates. Going a goal up and they went down to 10 men. We retracted when we should have gone out to get the second. We have made a mistake.
“We have given them three goals and dropped too deep in the second half, hanging on to the lead we had. Just before half-time, I thought it became a bit of a basketball game – it was end-to-end. We didn’t make the most of our opportunities and lost our structure.
“We ended up jumping out from midfield and they played through us. It is a bitterly disappointing dressing room as they know they can compete, but we lost belief in the second half. I don’t see too many positives at the moment but in the cold light of day, we will look back and analyse the game. The home games are going to be very important. We have had opportunities in all games and not fear anybody except maybe the Man City’s and Liverpool’s in this league.”