A hot spring works by discharging from underground. The water of a hot spring is heated by molten rock material that is cooling and solidifying underground.
All of the water that comes from a hot spring is heated by geothermal heat or heat that comes directly from the Earth's mantle. The temperature of the rocks within the Earth increase the deeper it goes. This means that as water reaches deeper into the Earth it becomes hotter due to the contact with the rocks. This situation only describes hot springs that are not near active volcanoes.
According to HowStuffWorks, most hot springs are located in places where there is or has been volcanic activity. For hot springs that are located near volcanoes, such as the one in the Yellowstone National Park, the water is heated by being in contact with magma. In some situations, the water becomes heated to the point where it begins to boil or it gets superheated. In these instances, the steam pressure can build up and erupt above the Earth's surface. When the hot water erupts in such a manner, it is called a geyser.
The temperature of a hot spring varies. Some springs have much cooler waters, which is why they are identified as warm springs.