Dennis' Turn 3 lock-up set the Briton off-line for the following hairpin, and he locked up for a second time to deliver a terminal blow to his chances of kicking off 2022-23 with a pole position.
This meant that di Grassi could back off and simply cross the line to bag pole position, while Dennis was upset having had to contest the final with a broken front wing - caused by contact with a bollard in the stadium section during his quarter-final with Pascal Wehrlein, which wiped out his right front wing endplate.
Di Grassi had also benefitted from a mistake in the semi-finals to progress to the battle for pole; a lock-up at the hairpin for his final-four adversary Andre Lotterer ended his chances of progressing to the final early on, giving di Grassi safe passage into the duel for pole uncontested.
This is di Grassi's first Formula E pole since the 2017 Montreal E-Prix.
Dennis had atoned for Lotterer's error to ensure an Avalanche Andretti driver made it into the final, as he won out in the battle of the Jakes in his semi-final with Jake Hughes.
Hughes had been ahead by just 0.03s by the end of the second sector, but his McLaren's wayward rear end forced a number of corrections through the Peraltada - which cost him enough time to hand proceedings in favour of Dennis. Lotterer's error puts him fourth on the grid, behind Hughes.
Di Grassi had earlier become the first driver of the season to book his place in the semi-final despite falling behind Sebastien Buemi in the opening two sectors, as the Swiss shipped over a tenth in the Foro Sol to result in a quarter-final exit.
Lotterer then bagged a semi-final place over Sacha Fenestraz; the veteran German dropped behind the rookie driver in the opening sector, but hauled his way ahead in the second part of the lap.
An all-British face-off between Hughes and Dan Ticktum fell in the McLaren driver's favour, despite the NIO 333 sophomore closing the gap towards the end of the run.
Dennis then held off the works Porsche of Pascal Wehrlein by just 0.029s to progress to the semi-finals; the Avalanche Andretti driver's 0.4s buffer was almost wiped out after his bollard contact, but it proved just enough to earn a place in the final four.
Ticktum starts behind Lotterer on the grid in fifth, as Wehrlein, Buemi and Fenestraz complete the order of the top eight.
In a hotly-contested group stage, Jean-Eric Vergne was the most surprising exit from Group A after a messy session, having previously blocked Sergio Sette Camara while the Brazilian was on a hot lap, and then was unable to make the most of clear track to get through.
Vergne also copped a black and white flag for stopping on track to find space, having been informed over the radio of clear track behind Buemi and pulling over after the stadium to get out of the traffic.
Fenestraz then dumped out Antonio Felix da Costa by just 0.002s to progress into the duels in his second Formula E race weekend, while Sette Camara, Rene Rast and Maximilian Guenther were also notable exits from Group A.
Sam Bird endured a miserable session after a lengthy lay-off in the pits, and he thus propped up the group as Abt's Robin Frijns had just 0.02s in hand.
Mitch Evans and Stoffel Vandoorne also dropped out of duels contention to leave Jaguar and DS Penske without a horse in the knockout stages, as Edoardo Mortara did not progress either.
At the death of the 12-minute session, Wehrlein was the only driver to improve at the flag and dumped Evans out in the process.
Da Costa starts ninth ahead of Evans, while Vergne's sixth place in his group puts him 11th alongside Nick Cassidy.
Mahindra bookends the grid, as Oliver Rowland was unable to pull himself off the bottom of his group and hence starts at the back.
Formula E Mexico City E-Prix - Starting grid
|1||Lucas di Grassi||Mahindra Racing|
|2||Jake Dennis||Andretti Autosport|
|3||Jake Hughes||NEOM McLaren Formula E Team|
|4||Andre Lotterer||Andretti Autosport|
|5||Dan Ticktum||NIO 333 Racing|
|6||Pascal Wehrlein||Porsche Team|
|7||Sébastien Buemi||Envision Racing|
|8||Sacha Fenestraz||Nissan Formula E Team|
|9||Antonio Felix da Costa||Porsche Team|
|10||Mitch Evans||Jaguar Racing|
|11||Jean-Eric Vergne||DS Penske|
|12||Nick Cassidy||Envision Racing|
|13||Sergio Sette Camara||NIO 333 Racing|
|14||Stoffel Vandoorne||DS Penske|
|15||René Rast||NEOM McLaren Formula E Team|
|16||Edoardo Mortara||Maserati MSG Racing|
|17||Maximilian Gunther||Maserati MSG Racing|
|18||Nico Müller||ABT CUPRA Formula E Team|
|19||Robin Frijns||ABT CUPRA Formula E Team|
|20||Norman Nato||Nissan Formula E Team|
|21||Sam Bird||Jaguar Racing|
|22||Oliver Rowland||Mahindra Racing|
|View full results|