The differences depend greatly on which country you are in. Some countries use a lot of fuel or coal to generate electricity. Others, like New Zealand, generate over 80% from more environmentally friendly methods.
But the most important thing to consider is that Petrol does not just flow freely from the pump without a complex process to get it there. This little video explores the complex cycle for getting petrol from the oil under the ground out to the pumps. And you can see that even more electricity is required for all these processes.
So in the end, if you just want to look at electricity as a dirty part of the EV, you can't say that petrol is cleaner. And then just consider that burning petrol ( or diesel ) creates horrible waste gases, and running an EV creates nothing.
In addition, as technology improves, electricity gets cleaner and cleaner. Petrol and Oil just make a mess during every part of the process.