The rest of the plumbing system, the part that recirculates the water and the part that drains it, involves the pump.
In the picture above, you can see how the pump is hooked up. This pump is actually two separate pumps in one: The bottom half of the pump is hooked up to the drain line, while the top half recirculates the wash water. So how does the pump decide whether to pump the water out the drain line or back into the wash tub?
This is where one of the neat tricks of the washing machine comes in: The motor that drives the pump can reverse direction. It spins one way when the washer is running a wash cycle and recirculating the water; and it spins the other way when the washer is doing a spin cycle and draining the water.
Let's take a closer look at the pump:
If you look carefully, you can see the vanes of the bottom layer of the pump. When water enters the pump's inlet, these vanes, or fins, push the water around and force it back out of the pump by way of the outlet. This type of pump can operate in both directions -- which port is the inlet and which is the outlet depends on which direction the pump is spinning in.
Take another look at the pump. If the pump spins clockwise, the bottom pump sucks water from the bottom of the wash tub and forces it out the drain hose, and the top pump tries to suck air from the top of the wash tub and force it back up through the bottom, so that no water recirculation takes place.
If the pump spins counter-clockwise, the top pump sucks water from the bottom of the tub and pumps it back up to the top, and the bottom pump tries to pump water from the drain hose back into the bottom of the tub. There is actually a little bit of water in the drain hose, but the pump doesn't have the power to force much of it back into the tub.
Take another look at the drain hose in the picture above -- notice how it loops all the way to the top of the machine before heading back down to the drain. Because one end of the hose is hooked up to the bottom of the tub and the other is open to the atmosphere, the level of water inside the drain hose will be the same as the level inside the tub. If the drain hose didn't go all the way up to the top of the machine, then the tub could never fill all the way. As soon as the water reaches the bend in the hose, it goes out the drain.
There are also times when the pump does not spin at all. The washer just churns the water that is in the tub without recirculating it. For this situation, the pump is hooked up to the motor by way of a clutch.
In this picture, you see the flexible coupling that hooks the clutch up to the pump. The coupling is needed because the motor and clutch are mounted to the frame, which can move freely with the inner tub, whereas the pump is mounted to the stationary outer tub.
On the bottom of the clutch is a set of four teeth. When the electromagnet engages, it raises an arm up into these teeth, which stops them from rotating. Once the teeth are stopped, the clutch starts to engage. After a couple of revolutions, it locks up to the motor shaft and the pump starts to turn with the motor.