Diesel engines are ubiquitous: They power everything from passenger vehicles to delivery trucks to bulldozers to trains to ships. The US Department of Energy (DoE) refers to them as the “workhorse engines.”

But in the past, they had a severe image problem. As the agency notes in a pamphlet detailing the basics of diesels, they were “dirty and sluggish, smelly and loud.”

“That image doesn’t apply to today’s diesel engines, however, and tomorrow’s diesels will show even greater improvements. They will be even more fuel efficient, more flexible in the fuels they can use, and also much cleaner in emissions,” the agency says.

Diesel engine is an internal combustion engine that converts chemical energy in fuel to mechanical energy. It is the mechanical energy that moves pistons up and down in the enclosed spaces called cylinders.

These pistons are connected to the crankshaft, whose movement switches from linear to rotary to propel the wheels.

As the fuel reacts chemically with oxygen, a series of small explosions occurs, releasing energy. In a diesel engine, the fuel ignites on its own.

“Air heats up when it’s compressed,” DoE says. “This fact led German engineer Rudolf Diesel to theorize that fuel could be made to ignite spontaneously if the air inside an engine’s cylinders became hot enough through compression.”

The inventor of the diesel engine calculated that high compression should lead to high engine efficiency. “Part of the reason is that compressing air concentrates fuel-burning oxygen,” the agency says.

And if a fuel has high energy content per gallon and is injected into the cylinders at the right time, it should react with most of the concentrated oxygen to deliver “more punch per explosion.”

DoE says Mr. Diesel’s calculations were correct. “As a result, although diesel engines have seen vast improvements, the basic concept of the four-stroke diesel engine has remained virtually unchanged for over 100 years.”

The first stroke involves the air being sucked into a cylinder while the piston creates a space for it by distancing itself from the intake valve. After the piston swings upward, the air is compressed and heated. Before the piston reaches the top of its compression stroke, the fuel is injected under high pressure and then ignites spontaneously upon contact with the heated air.

“The hot combustion gases expand, driving the piston downward in what’s called the power stroke. During its return swing, the piston pushes spent gases from the cylinder, and the cycle begins again with an intake of fresh air,” DoE says.

Gasoline engines, like diesel engines, work by internal combustion. They have slight differences, though.

“In a gasoline engine, fuel and air is injected into small metal cylinders. A piston compresses (squeezes) the mixture, making it explosive, and a small electric spark from a sparking plug sets fire to it. That makes the mixture explode, generating power that pushes the piston down the cylinder and (through the crankshaft and gears) turns the wheels,” explains Chris Woodford, a British science writer who runs the Web site Explain that Stuff.

Mr. Woodford notes that theoretically the gasoline engine, with its spark plug, should be more efficient than the diesel engine. The reality is different: It is the diesel engine that is substantially more efficient than the gasoline engine.

“In simple terms, that means you can go much further on the same amount of fuel (or get more miles for your money),” he said. One reason is that the fuel is easily compressed in the diesel engine because it requires no sparking-plug ignition system.

“There’s another efficiency saving too. In a gasoline engine that’s not working at full power, you need to supply more fuel (or less air) to the cylinder to keep it working; diesel engines don’t have that problem so they need less fuel when they’re working at lower power,” Mr. Woodford said.

The fuel that diesel engines use also gives them several more advantages. Diesel fuel, which Mr. Woodford described as a lower-grade and less refined petroleum product made from heavier hydrocarbons, contains more energy per gallon because the molecules have more energy locking the atoms together.

“Diesel is also a better lubricant than gasoline so a diesel engine will naturally run with less friction,” Mr. Woodford said.