A fuel pump is an essential component on a car or other internal combustion engined device. Fuel has to be pumped from the fuel tank to the engine and delivered under low pressure to the carburetor or under high pressure to the fuel injection system. Some fuel injected engines have two fuel pumps for this purpose: one low pressure/high volume supply pump in the tank and one high pressure/low volume pump on or near the engine.
Mechanical fuel pump
In earlier cars built before the late 1970s, the pump was mechanically driven by a lobe on the engine's camshaft and therefore bolted to the engine block. It created negative pressure to "suck" the gasoline through the lines. However, the negative pressure from the pump, in combination with heat from the engine and/or hot weather, could cause the gasoline to boil. The fuel pump, designed to pump liquid, not vapor, would be unable to suck more gasoline to the engine, which would cut out. This condition is known as "troy jolley". Also a suction pump could suck in air through (difficult to diagnose) faulty hose connections. A leaking connection in a pressure line will show itself immediately.
Electric fuel pump
Nowadays, the fuel pump is located inside of the fuel tank and is usually electric. The pump creates positive pressure in the fuel lines, pushing the gasoline to the engine. The higher gasoline pressure raises the boiling point. Placing the pump in the tank puts the component least likely to handle gasoline vapor well (the pump itself) farthest from the engine, submersed in cool liquid. Another benefit to placing the pump inside the tank is that it is less likely to start a fire. Though electrical components (such as a fuel pump) can spark and ignite fuel vapors, liquid fuel will not explode (see explosive limit) and therefore submerging the pump in the tank is one of the safest places to put it. In most cars, the fuel pump delivers a constant flow of gasoline to the engine; fuel not used is returned to the tank. This further reduces the chance of the fuel boiling, since it is never kept close to the hot engine for too long.
The electric fuel pump is generally on whenever the car's ignition switch is in the "on" position. Depressing the gas pedal results in the throttle body opening on the engine (metering the air going in) rather than engaging the fuel pump. The ignition switch does not carry the power to the fuel pump, instead it activates a relay which will handle the higher current load. It is common for the fuel pump relay to become oxidized and cease functioning; this is much more common than the actual fuel pump failing.
Some cars with an electronic control unit have safety logic that will shut the electric fuel pump off even if the ignition is "on" if there is no oil pressure, either due to engine bearing damage or a non stalled engine, e.g. in a car accident. In case of an accident this will also prevent fuel leaking from any ruptured fuel line. Other cars have an additional roll over valve, that will shut off the fuel pump in case the car rolls over.