Pistons are at the very heart of the reciprocating internal combustion engine, which is why they are often called a "piston engine". At its most basic, the piston is simply a solid cylinder of metal, which moves up and down in the hollow cylinder of the engine block. The piston itself is slightly smaller than the hole it moves in, but it has piston rings under tension to achieve an (nearly) air-tight seal once it is installed within the engine cylinder. The piston is attached via a wrist pin to a connecting rod, which in turn is connected to the crankshaft, and together they turn the up and down (reciprocating) motion into round and round (rotational) motion to drive the wheels.
Internal combustion engines can operate with just a single cylinder and therefore one piston (motorcycles and lawnmowers) or as many as 12, but most automobiles have four, six, or eight.
Pistons also feature in external combustion engines, otherwise known as steam engines, where water is heated in a boiler and the resulting steam is used to propel pistons in external cylinders, which then drive the wheels.
In a rotary engine, there are no pistons, cylinders, or valves, just triangular-shaped rotors spinning around. But there are currently no Wankel rotary engines in production, the last one being the Mazda RX-8 in 2012. In every four-stroke (gasoline or diesel) car engine, the intake, compression, combustion, and exhaust process takes place above the crown of the piston, which forces the piston to move up and down (or side to side in horizontally opposed engines, like the Porsche or Subaru) within the cylinder. The piston pushes upward compressing the fuel and air into a much smaller space in the cylinder head, where it is then ignited by the spark plug. The resulting explosion forces the piston downward, creating exhaust gases. A much more complete explanation can be found here or in the animation below.
What are pistons made of?
Engine components today need to be tough for longevity and lightweight to improve efficiency, which means all pistons are some form of aluminum alloy. But back in the dawn of the horseless carriage era pistons were made of cast iron because they were very long wearing, and resistant to heat that could quickly melt aluminum. As metallurgy progressed, and temperatures were kept under better control through more efficient design, the lightness of aluminum quickly won out, and allowed much higher RPM to be achieved.
The piston rings continued to be made out of cast iron and steel alloys, because of their higher spring constant. The ring package usually comprises, from top to bottom, a compression ring, a wiper ring and an oil ring all made from cast iron or steel.
The compression ring seals the gap between piston and cylinder. The second, wiper ring, contributes to the compression as well as wiping excess oil off the walls of the cylinder as the piston moves downward. The oil ring, is actually made of 2 rings and a spreader in most motors, and also wipes oil from the cylinder wall, then allows it to drain back through small holes in the ring land. But over time the rings can wear and lose their elasticity, allowing oil from the crankcase to move into the combustion chamber. Excessive oil consumption and bluish smoke from the tailpipes usually indicates piston ring wear.