A Magic User or an Illusionist can try to counter any spell that an opponent is casting. The process is as follows:
The PC must know the spell being cast, though he need not have it prepared for the day.
The PC and the opponent roll d20 modified in the following ways. If the PC does not have the spell memorized he is penalized -5 in his roll (if the spell is memorized there is no penalty, but see below). The difference in level between the PC and the opponent is added to the higher level magic-user's roll. The rolls are made and the highest roll wins (either the spell is countered or the spell cast to normal effect).
Attempting to counter a spell has a cost associated with it as follows. If the PC attempting to counter the spell has the spell prepared for the day, he will lose the ability to cast the spell in the attempted counter (whether or not the countering was successful) for the rest of the day (until such time as the spell can be re-prepared). If the PC does not have the spell memorized, he loses 1 point of constitution per level of the spell attempted to counter. The CON loss is temporary, regained at a rate of one point per hour, regardless of activity.
If the counter is successful, the magic-user whose spell was countered is stunned for one round (unable to perform any action but move at one-quarter speed) and loses the spell. There is a 5% chance (natural 20 on the part of the counterer) that the countered magic-user will be knocked unconscious for 2-12 rounds. A natural 20 on the part of the original caster means no only does the spell succeed, but that the counter spell caster's level is added to the caster's in order to determine effect (that is, a 5th level mu tries to counter a 4th level mu, fails as the 4th level mu rolls a natural 20 which means automatic success and the spell is now cast at 9th level).
For example, Gavin is a 6th level magic user. He sees the Big Bad Evil Guy (who is a 9th level magic user) is about to cast fireball. Gavin has fireball memorized, so he tries to counter the BBEG's spell. He rolls a 14 and the BBEG rolls a 12, which is further modified by the level difference (+3) to be 15. Thus, the spell is not countered, and Gavin loses the possibility to cast fireball until he takes time to re-prepare it.
Example 2: Gavin is a 6th level magic-user. He sees the Big Bad Evil Guy (who is a 9th level magic user) is about to cast fireball. Gavin does not have fireball prepared for the day, though it is in his spellbook. He decides to try to counter it, suffering a -5 penalty on his roll, since he does not have it memorized. He rolls well, a 16, modified to 11. The BBEG rolls very badly, a 4, modified to 7 by the level difference. The spell is countered. The BBEG is stunned for a round and Gavin loses 3 points of constitution.