Extremely hot rocks present below the surface of earth heat the underground water and turn it into steam. As more and more steam is formed between the rocks, it gets compressed to high pressures. This high pressure steam is brought up through pipes and is used to run the turbine of a generator to produce electricity.