The geothermal gradient is the amount that the Earth’s temperature increases with depth. It indicates heat ﬂowing from the Earth’s warm interior to its surface. On average, the temperature increases by about 25°C for every kilometer of depth. This difference in temperatures drives the flow of geothermal energy and allows humans to use this energy for heating and electricity generation. There are a number of places on the planet where the temperature changes quite a bit faster though, and those locations are almost always where geothermal energy is the most viable.
The interior of the Earth is extremely hot, and reaches temperatures over 5000°C near the core, which is not much colder than the surface of the Sun (the interior of the sun however is much hotter).
It was discovered in the early 20th century that the Earth's underground heat is from radioactive elements. Specifically, geothermal heating is caused by the decay of elements such as potassium, uranium and thorium. These elements are not found in the core however, with the most popular model suggesting that they are found in the lithosphere and mantle. This form of heating is said to account for 50% of the Earth's heat, with the other heat coming from the primordial heat of the Earth (heat from the Earth's formation that has been trapped in the planet).
Figures 2 and 3 below shows how temperature decreases as it approaches Earth's surface, along with the mechanisms of heat flow. Overall, temperature changes are gradual except near the base of the mantle where drastic compositional changes occur, and in the lithosphere where the presence of fluids has a large effect.
Figure 2. Temperature profile of the Earth's layers. Temperature increases with depth.
Figure 3. Heat transfer mechanisms within the Earth, along with the % amount of heat flow in each layer.