A spell is an invocation of arcane or divine power by a spellcaster to produce effects not achievable through more mundane means. Neverwinter Nights defines almost 300 spells for player characters to cast, distributed among the caster classes. (Each class can cast a subset of the game's spells, with overlap between classes.) While casters are divided into arcane and divine, there is no functional difference for spells themselves. For example, dispel magic has the same uses and results whether cast by a bard (arcane caster) or a cleric (divine caster).
Spells can also be cast from certain items, sometimes by non-spellcasters.
Spells can be modified by metamagic.
There are various ways in which spells are classified. The most significant of these might be spell level, which is a general indication of the power of the spell ranging from 0 to 10. (More precisely, "spell level" depends on the spell and the class casting it; "innate level" is an indication of spell power that is independent of the caster.) A novice caster can only cast the lowest level spells, while level 10 spells are reserved for epic classes.
Another major classification of spells divides them into eight schools of magic. These schools represent the different mechanisms behind the spells (story-wise; these mechanics are not actually part of the game). The school of a spell does not affect who can cast the spell (aside from those wizards who have specialized in a school), but can affect the ability of targets to resist the spell. The spell focus and arcane defense feats may be most notable in this regard, but there are other examples (such as shadow shield).
The results of a spell are sometimes classified through the spell's descriptor. The descriptor is significant for saving throws, as saving throws are usually made "versus" the spell's descriptor, and this can affect whether or not the target passes the save (sometimes in the form of bonuses, sometimes as immunity). Outright immunity to a spell's descriptor is supposed to make a creature immune to that spell, although exceptions and bugs do exist. (These bugs are more common when a spell's effects are technically not a match for the descriptor, as with Tasha's hideous laughter.)
While a large number of spells are available to the spellcasting classes, a more limited number are available for casting by an individual character at any given time. For sorcerers and bards, this limitation is implemented by a limited number of "known" spells, with the known spells selected at level-up. The other spellcasting classes make use of a spellbook to prepare their spells on a daily basis.
For a character, preparing spells occurs while resting. It involves the character studying, meditating, or praying (as appropriate for the casting class) with a focus on those particular spells that are to be available for casting the next day. This aspect is handled automatically by the game, based on assigned spell slots. Players use the spellbook interface to assign spells to slots, indicating which spells the character will prepare each day. (These assignments are remembered, relieving the player of the need to make assignments before each rest.) Only prepared spells can be cast, and they can only be cast as many times as they have been prepared. (Assigning a spell to multiple slots causes the character to prepare it multiple times.)
A spell can be prepared only if the character's current (modified) and base casting ability (intelligence, wisdom, or charisma, depending on class) is at least 10 plus the spell's level. Additional spells of a given level may be prepared based upon the character's current casting ability modifier.
Spells are cast using either the radial menu (upper-right option) or a quickslot. Spells cast through the radial menu will target the object or location from which the radial menu was invoked (and spells will be disabled in the menu if that target is invalid for that spell). Spells cast through a quickslot usually require clicking on a target after using the quickslot (and the cursor will be disabled if hovering over an invalid target). However, a spell that can only target the caster will only require clicking on a target if the inventory panel is open; this is to accommodate the item creation feats (e.g. scribe scroll) while maintaining convenience when the inventory panel is closed.
Once the target of the spell is selected, the remaining casting mechanics are handled automatically by the game. If the target is beyond the range of the spell, the character will move to be within range. Then the casting animation begins (indicated in the combat log as "<someone> casting <spell>"). When the animation is complete (indicated in the combat log as "<someone> casts <spell>"), the spell takes effect. If the target is a creature, the spell will target where the creature is at the time the casting is complete, making it possible to hit moving targets with a spell. If the spell has a chance of missing (requires a touch attack, allows a saving throw, or checks spell resistance), the game makes the required die rolls and reports the results to the player.
In addition to a spell missing its target, it is possible for the casting of the spell to fail. This can be due to counterspelling; a spell failure effect; a failed concentration check if damage is received during the casting animation or while in defensive casting mode; or the lack of a spell component. Failed concentration checks become more likely if the caster is within melee range of an enemy, as casting a spell usually provokes an attack of opportunity from each such enemy, and the damage from this attack of opportunity will occur before the casting animation ends. These attacks of opportunity (but not necessarily all sources of damage) can be avoided with defensive casting mode or the improved combat casting feat. Lacking a spell component can be the result of being subject to silence when the spell in question has a verbal component, or of being subject to armor/shield arcane spell failure when the spell in question has a somatic component and is being cast by an arcane class.
Once a spell is successfully cast, the objects that will be affected by the spell are selected. Most harmful spells use "standard hostile" targeting, which allows them to hurt party members unless this is disallowed by the PvP setting. Only a few harmful spells use "selective hostile" targeting, which spares anyone who is not an enemy. The targeting schemes are described more fully under area of effect.