Immunity is an avoidance mechanic available to both players and NPCs. It can be triggered by both items and spells, and it is also sometimes native.
When immune to a spell or ability, a player will not be affected by neither its damage nor any secondary effect triggered by it. Temporary immunity also clears out all debuffs of the affected schools.
Nearly all Elementals are natively immune to their own spell school. Abilities such as Divine Shield and Ice Block grant temporary total immunity. Since Patch 1.6, Immunity can also affect mechanics by themselves, such as root, snare, etc. A mob immune to snares will show up "Immune" when hit by a Concussive Shot, but not when hit by a Frostbolt; the mob will not be snared by the Frostbolt but will still take damage normally.
If a player becomes immune to all abilities a mob can perform it will switch to the next highest target on aggro (unless there are no other targets on its aggro table).