Photoallergy is an immune-mediated skin reaction that occurs when a chemical substance applied to the skin is altered by exposure to ultraviolet (UV) light, usually from the sun, to form a new compound that the immune system recognizes as foreign. This process is different from phototoxicity, which does not involve the immune system and results in more immediate skin damage.