Debuff Immunity

Spell immunity (formerly known as magic immunity) is a modifier which prevents most spells to target the affected unit. This includes single-targeted spells, area spells, passive and active abilities.

Spell immunity may be the main part of a spell, but it also is used as an extra layer of protection by some abilities (usually combined with invulnerability).

Mechanics
Spell immunity is a status effect (also known as modifier). Most spells in the game first check whether or not the unit has the spell immunity modifier on. If the modifier is present, single target spells cannot target the unit at all, while area of effect spells ignore the unit and already ongoing effects may stop affecting it. However, some spells (and most ultimates) pierce spell immunity and can fully target and affect spell immune units.

Usually, a spell either fully pierces spell immunity, or it is fully blocked. However, there are a few exceptions to this rule. Whether or not a spell pierces spell immunity is noted down in the description boxes of each ability, right below the ability name.

When a unit turns spell immune while a projectile from an ability is already flying towards it, the projectile has no effect upon impact if the spell it originates from does not pierce spell immunity. The same applies to most, but not all delayed effects.

Spell immunity does not prevent regular attacks of any units. However, some attack modifiers do get blocked, but not all of them. Generally, all critical strikes, cleaves and most bashes pierce spell immunity.

Damage interaction
Spell immunity itself does not interact with damage at all. If an ability pierces spell immunity and has a damage component, its damage will get applied normally, regardless of its damage type.

If an ability does not pierce spell immunity, it does not attempt to damage spell immune units either, regardless of the damage type. In order for a spell to damage spell immune units, it must be set to pierce spell immunity, or it must be already affecting it in case of buffs/debuffs.

Dispelling
Most sources of spell immunity also dispel the target upon getting applied, removing all buffs or debuffs a basic dispel can remove. The dispel applied by spell immunities is usually a basic dispel. However, not all of them apply a dispel, and some apply a strong dispel. A list of dispellable effects can be found here.

Since dispels only remove buffs from enemies and debuffs from allies, it is possible for units to turn spell immune without losing any buffs or debuffs, however, since spell immunity cannot be applied to enemies, it cannot be done in a regular match. In this case, most buffs/debuffs still apply their effects normally. Only a few of them are inactive while the unit is spell immune. This means that a damage-over time spell may still damage the unit.

Sources of spell immunity
These abilities grant spell immunity as a main part of the spell. They also apply a basic dispel upon cast.

These abilities also apply spell immunity. However, they only grant spell immunity as an extra layer of protection on top of the invulnerability they grant. This means their spell immunity only matters for spells which can affect invulnerable units (e.g. can target invulnerable units, but not spell immune units). These abilities do not apply the special spell immunity dispel like the above sources. However, some of them still do dispel, independent from the spell immunity.

Some non-hero units gain permanent spell immunity by other means.

Spell immunity on allies
Every not-targeted spell, be it an area spell or a spell which affects self upon cast, pierces spell immunity for allies and self, with a very few exceptions listed below. All runes apply their effect on spell immune units.

Spell immunity on enemies
Spells interact very differently when facing spell immune enemies. Most of them cannot affect spell immune units, some of them can only affect them partially, and some fully pierce spell immunity.