Entering counterspell mode allows a caster to prevent an enemy caster from casting spells. This is done by first identifying the spell being cast (using spellcraft), then sacrificing a readied spell slot containing a counter to the spell being cast. Lesser dispel (level 2), dispel magic (level 3), greater dispelling (level 6) and Mordenkainen's disjunction (level 9) are universal counters, able to counter any spell of the same level or lower with the exception of greater dispelling, which will only counter spells level 5 or lower. In addition, each spell is its own counter, and many spells also have specific counters, as listed in each spell's description. For example, haste can be countered by sacrificing a casting of slow. The selection of which slot to sacrifice is made automatically by the game, with specific counters given priority over universal counters. Note that, among available universal counters that would work against a given spell, the lowest level counter will not necessarily be used before higher levels ones. Epic spells cannot be countered.
Counterspell mode is entered by right-clicking the caster to be countered, then selecting the "Counterspell" option in the radial menu (top-right option "Cast Spell", followed by leftmost option "Spell Special Abilities", then the topmost option). This is a combat mode, so cannot be used at the same time as other combat modes. Any action other than counterspelling, such as an (involuntary) attack of opportunity, will end this mode. Entering counterspell mode will end stealth mode, but counterspelling does not count as a hostile act for purposes of ending invisibility, greater sanctuary, etc.. Counterspelling will break the concentration needed to maintain a black blade of disaster.
A hasted caster can only be countered by a hasted counterspeller. Otherwise, the speed at which spells are cast does not affect the ability of a single character to counterspell each one. That is, any caster can potentially counter two spells per round if countering a mage casting quickened spells (even if the counterspeller is unable to cast quickened spells). If a counterspeller is already in counterspell mode when a time stop effect begins, he will continue countering during the time stop.
Note that NPCs may have what appear to be normal spells available to them as special abilities. These cannot always be countered, though the ability may appear just like a normally cast spell in the combat log.