The main purpose of stress relief is the elimination / reduction of residual stresses created by machining, forming, cold working or welding operations.
Stress relieving is done by heating at a temperature below the lower transformation (Ac1) temperature of steels and cast irons.
The usual procedure is to heat to a pre-established temperature for a time long enough to reduce residual stresses to an acceptable level (this transformation is dependent on time at heat but much more importantly, temperature. For efficient elimination / reduction of residual stresses, a temperature above 1050o F / 565o C should be selected.
Finally, cooling is done at a rate slow enough to avoid the introduction of new stresses.