In 3e it wasn't a spell, it was a thing you could try to do if you had the right spell prepared: either the same spell being cast, a spell that specifically counters it, or dispel magic. IIRC, you also had to ready your action.
So to counter a fireball spell, you need to have fireball prepared, and then guess which turn the enemy will cast it, and use your turn before to ready an action to counter it. If the enemy doesn't try to cast fireball, you wasted your turn.
If you have dispel magic prepared, you could ready you action to counter any spell, but then you get into an odd metagame situation where the dm needs to decide if the lich knows what you're doing and can respond with that knowledge or not.