Spells fall into two main categories: wizardry spells and prayers. Casting wizardry spells requires spell points and the applicable skill for each spell. Casting prayers requires grace from a god and the praying skill.
Spell details and more information about the skills needed are at the following links.
To learn spells, players must posses both the applicable skill and the literacy skill. A characters skill level in literacy must be no less than 10 levels lower than the desired spell (e.g. a level 20 spell requires at least level 10 literacy to learn). Blessed spellbooks can be learnt 5 levels earlier than regular books. Cursed books remove spell points or grace and unlucky players can actually forget a spell.
Characters aren't guaranteed success in learning a spell, rather a character's chance to learn a spell is:
% chance to learn = (base chance + (2 * level))/1.5
|# stat points||% Base Learn Chance|