Germany's Pascal Wehrlein had led from pole position in a race that was red-flagged after less than five minutes when Brazilian Nelson Piquet Jr. had a big smash.
'Absolute chaos' - Piquet crashes in Mexico City
Formula E Puebla talking points: Mortara sets down marker, Di Grassi ends drought
Wehrlein led from the re-start but used too much energy defending on the last lap against Di Grassi and ran out of power within metres of the finish line as the former champion sped past to win for Audi at the Hermanos Rodriguez circuit.
"I think it was my best Formula E race ever," said Di Grassi, the fourth different winner in four races. "It was unbelievable.
Wehrlein was very dodgy, closing the door and changing direction many times.
"I tried to put pressure on him, making him use energy and then in the last corner he just slowed down, tried to close the door and I crossed the line sideways."
Mahindra driver Wehrlein, one of several ex-Formula One drivers in the series, was handed a five-second penalty after the finish for cutting a turn on the final lap, dropping him from second to sixth.
That left Portuguese Antonio Felix Da Costa in second place for BMW Andretti and Swiss racer Edoardo Mortara third for Venturi. D'Ambrosio finished fourth, from 19th on the grid, to take over at the top of the standings on 53 points, seven clear of Da Costa on 46 and Britain's Sam Bird, the previous leader who dropped to third on 45.
Brazilian Felipe Massa, the former Ferrari and Williams F1 driver, scored his first points in Formula E with eighth place for Venturi, the Monaco-based team led by Britain's Susie Wolff. Bird was ninth. Mahindra lead the team standings with 83 points to Bird's Virgin outfit on 73.
Vergne wins behind the Formula E safety car in Rome
Formula E 2021 season preview: Mercedes gunning for glory