Basically both.
Spells detects attack type. So if a unit is magic immune, spells will not affect them.
Magic detects damage type. It gets affected by armor, as mentioned above. And so is other spell reduction abilities.
Then again, it could be vice versa. The terms are pretty confusing sometimes.