In a petrol engine, the air-fuel mixture is compressed by the piston, and then ignited by a spark plug. This creates a controlled burn that drives the piston down, generating power.
In a diesel engine, the air is compressed to a much higher pressure than in a petrol engine, which causes it to heat up and ignite the diesel fuel without the need for a spark plug. This process is called compression ignition.
Diesel engines are more efficient than petrol engines, but they also produce more emissions. Petrol engines are more responsive and have a smoother power delivery, but they are less efficient and produce more emissions.
The choice of engine type for a particular application depends on the desired performance characteristics and the emissions regulations that apply.