Lucas di Grassi won a thrilling Mexico City ePrix after making an early pit stop under the safety car.

The Brazilian closed the gap between him and Buemi to just four points, with Buemi finishing outside of the top ten for the first time this season. His pit stop under an early safety car looked to be a very big risk, but he was able to make it work.

Oliver Turvey made his way into the lead at the start, with Jose Maria Lopez keeping in second, with multiple cars making contact at different times during the first lap, causing the safety car to be deployed. This helped Lucas di Grassi, who damaged his rear wing in a collision with Maro Engel at the first chicane during the opening lap.

Race leader Turvey then ran into power issues at the beginning of Turn 13, losing the lead of the race as his car came to a halt at the pit lane exit. For multiple laps he tried to get it started again with a yellow flag being shown at the first chicane, although after three laps hope was lost for the Brit and the safety car was brought out again.

Getty Images Latam/Getty Images Sport

The race restarted on Lap 19, with Lopez leading Nick Heidfeld and Jean-Eric Vergne. Jerome d’Ambrosio and Di Grassi made the gamble to change cars during the second safety car period, whilst  Vergne was the first of the front runners to pit on Lap 25, with the majority making their car changes a lap later.

After the pit stops Di Grassi and D’Ambrosio led the race, with Lopez and Vergne in third and fourth. The safety car came out for a third time after Loic Duval stopped on track.

Racing got underway not long later, and the fight between Lopez and Vergne started to heat up with d’Ambrosio not far in front. Lopez took himself out of contention on Lap 35, spinning his car going into Turn 1 while trying to pass d’Ambrosio around the outside. Buemi also made a similar mistake further behind, nearly hitting Lopez as he made his way back on track.

With five laps to go Di Grassi found himself having to start preserving energy even further, although he had a five-second gap to the rest of the field. D’Ambrosio locked up at the start of Lap 43, and while he was able to make the turn Vergne was able to take over second place.

Handout/Getty Images Sport

A manic incident ensued later in the lap, resulting in the two Mahindra drivers colliding. The safety car did not come out again, but Di Grassi was somehow able to stay in front to win the Mexico City ePrix.

Vergne took a deserved second place with Bird taking the final podium spot. Mitch Evans had a quiet performance but was able to finish in fourth place, picking up Jaguar Racing’s first points in Formula E. Nico Prost rounded off the top five.

Lopez was able to cross the line in sixth after his spin a few laps earlier, with Di Grassi‘s teammate Daniel Abt behind in seventh. Jaguar Racing also got more points from Carroll finishing eighth, while Nelson Piquet Jr gathered some points for NextEV NIO. Esteban Gutierrez finished in 10th, scoring one point in his first Formula E race.