Mexico City E-Prix winner Lucas di Grassi said his intense late battle with Pascal Wehrlein was the best drive of his career, after the Brazilian made a stunning overtake just metres from the finish line to win one of the most dramatic races in Formula E history.

The Brazilian former Formula E champion was behind Britain’s Oliver Rowland and Mahindra’s Wehrlein for much of the race but managed to pass both rookies late on to secure his first win of Season Five of the ABB FIA Formula E Championship.

The pair were both punished by the new 45-minute timed format of Formula when they both ran out of energy late on – a full-course red flag from a huge crash five minutes in throwing many teams’ plans out of the window.

For Wehrlein, it was a desperately frustrating missed opportunity to get his first win in the series, having secured pole position and then lead from the start until the very last corner. As the German hit 0% he attempted to coast over the finish line to avoid a penalty while blocking Di Grassi, only for the Audi Sport ABT Schaeffler driver to squeeze past to take the win.

Di Grassi, still visibly excited after a topless podium celebration, explained: “I pretended to go to the outside and he opened a small door – just enough for the car to fit between the wall and the car and I went there. I couldn’t believe it. My adrenaline is still super high. It was amazing.

“I knew he was running out of energy so I was putting pressure to overtake in the last five lap.

“This was probably the best Formula E race of my career because it was a mixture of having the patience to save energy in the beginning and then making the moves in the correct moment.”

Di Grassi was joined on the podium by BMW’s Antonio Felix da Costa and Venturi’s Edoardo Mortara after Wehrlein was penalised further after cutting a corner which saw him finish sixth, following a five-second time penalty.

The race was not short of incident, with red flags shown just a few minutes into the E-Prix after Panasonic Jaguar racing’s Nelson Piquet Jr had a huge collision with Techeetah’s Jean-Eric Vergne. Piquet Jr was sent airborne into the wall at high speed but managed to walk away unscathed.

Felipe Massa scored his first points in Formula E, after a fantastic showing in qualifying to start third on the grid although a final position of eighth will have disappointed the Brazilian who had an eye on his first podium. And fellow ex-F1 driver Stoffel Vandoorne remains pointless since switching to the all-electric series finishing 18th.