http://www.m-diesel.com/news/how_diesel_engines_work-en.html
A diesel engines main purpose is to create energy through a cycle of controlled explosions inside a small chamber.
There are 4 main phases to the cycle of a diesel engine, each one involving a stoke of a mechanical piston in the engine. These are termed the intake, compression, combustion, and exhaust, strokes.
During the intake stroke phase, an air intake valve opens up, letting in air as the piston moves down in the chamber.
Next during the compression stroke the air intake valve that was just opened closes which seals off the chamber. Then the piston moves up and compresses the air inside the chamber creating heat.
This heat then helps to ignite the fuel during the combustion stroke. During this phase a fuel injector sprays a mist of tiny droplets of evenly distributed diesel fuel directly into the chamber at the perfect moment just before the piston reaches the top of the cylinder. The fuel injector ensures that an optimal amount of fuel is used. The combination of air, fuel, and heat resulting from compression of the chamber, causes combustion. This explosion forces the piston back down and creates the power needed to turn the wheels.
After the piston has been forced down comes the exhaust stroke. An exhaust valve opens and the piston comes up to the top once more to let out the fumes from the previous cycle. After that the process starts over from the beginning with the intake stroke as the piston moves back down.
Diesel engines have a number of advantages over a typical gas engine. First they burn less fuel for the same output, this allows them to operate at up to 15% more efficiency when creating energy from fuel. They also last longer due to the lubrication properties of diesel fuel, and the extra strength of the parts and metals used. Diesel is also considered safer than regular petroleum because of its low vapor, and because it will not explode in a low compression situation, instead it just burns. Diesel engines also have low carbon monoxide exhaust, allowing them to be used in close proximity to humans in enclosed areas, like mines. A final important advantage is diesel engines do not have a high voltage electrical ignition system, which increases their reliability, and lowers the chance for electrical interference with radio equipment which is especially necessary in marine and aircraft applications.