Sunburn occurs when the skin is overexposed to ultraviolet (UV) rays from the sun, leading to damage at the cellular level. This damage triggers an inflammatory response, which can result in redness, pain, and, in severe cases, blistering. If the damage penetrates deeply enough, it can affect the dermis, leading to scarring.