Lucas di Grassi stole victory at the finish line of ABB FIA Formula E's race at Mexico City as long-time race leader Pascal Wehrlein suddenly ran out of energy.
In what turned into a thrilling finish to a disrupted race, di Grassi had been putting pressure on Wehrlein - attacking at the right-hand Turn 1 on the final lap as he tried to make a late-race energy advantage pay.
Wehrlein rebuffed him there, but when di Grassi attacked down the inside at the following Turn 3 - the track's main overtaking spot - Wehrlein stayed alongside and cut the following corner.
Di Grassi did not give up and caught up to Wehrlein by the final chicane, with the Mahindra driver again defending the inside.
But Wehrlein's energy ran out on the run to the line and di Grassi nipped towards the pitwall to take the win by half a car.
Antonio Felix da Costa finished third on the road but was promoted to second after Wehrlein was given a five-second post-race penalty for cutting Turn 4 on the final lap, which boosted Edoardo Mortara to third and dropped Wehrlein to sixth.
Wehrlein had led for most of the race ahead of Nissan e.dams driver Oliver Rowland, who jumped from fourth to second at the race's first corner after Wehrlein had defended his lead from di Grassi off the line.
But before the race had settled down, it was suspended following a massive accident between Nelson Piquet Jr and Jean-Eric Vergne.
The pair were fighting over eighth on the run to the final chicane on lap three, with Vergne moving across to cover the inside for the right-hand Turn 14.
As they arrived at the corner, Piquet smashed over the back of Vergne's car and shot into the air, clipping the rear of Alexander Sims's car before hitting the wall on the outside of the track.
A full course yellow was initially called before the race was suspended and Wehrlein led the pack into the pitlane, where Vergne's team worked to fix the rear of his car.
At the safety car restart, following a 30-minute suspension, Wehrlein, Rowland and di Grassi gapped Sebastien Buemi and da Costa by taking using their first attack mode on the last of two safety car laps, with Buemi among a number of drivers activating the system immediately after leaving the pits.
For the next 28 laps of what would become a 45-lap race, Wehrlein sustained the pressure from behind, with Buemi and da Costa only catching the leaders late on.
Da Costa took his second attack mode on lap 32, with Buemi, di Grassi and Rowland doing likewise in succession on the following three laps.
When Rowland took his second activation, he went wide at the end of the attack mode zone and di Grassi nipped through at the exit of the stadium section to take second, with Rowland and Buemi clashing at the final chicane a few seconds later.
Di Grassi roared up to Wehrlein to set up the thrilling finale, but Rowland and Buemi ran out of energy with a lap still to run and dropped down to 20th and 21st in the final classification.
That promoted da Costa and Mortara, who had made it a six-way fight for the win late-on, and Jerome D'Ambrosio took fourth ahead of Andre Lotterer after a sensational rise through the chaos from 19th on the grid. That result put D'Ambrosio back into the championship lead.
Mitch Evans finished seventh for Jaguar and had a mid-race clash with Vergne, who ended up down in 13th after being spun around in the incident.
Felipe Massa scored his first FE points with eighth. He had qualified third but fell down the order having taken his second attack mode earlier than his rivals.
Sam Bird and Daniel Abt also made a brilliant rises from 22nd and 21st on the grid respectively to take the final points in ninth and 10th.
Sims ended up 14th after his car was also repaired under the red flag.
|1||Lucas di Grassi||Audi||Audi||45||1h13m15.422s|
|2||Antonio Felix da Costa||BMW||BMW||45||0.436s|
|5||Andre Lotterer||DS Techeetah||DS||45||1.785s|
|13||Jean-Eric Vergne||DS Techeetah||DS||45||19.153s|
|17||Jose Maria Lopez||Dragon||Penske||45||41.542s|
|20||Oliver Rowland||e.dams||Nissan||44||Out of energy|
|21||Sebastien Buemi||e.dams||Nissan||44||Out of energy|
|-||Nelson Piquet Jr.||Jaguar||Jaguar||2||Accident|
|2||Antonio Felix da Costa||46|
|4||Lucas di Grassi||34|
|17||Jose Maria Lopez||2|
|18||Nelson Piquet Jr.||1|