To counterspell requires targeting the caster and casting the counterspell as one would cast a normal spell.
Invisibility (the spell, at least) ends when casting "any spell targeting a foe or whose area or effect includes a foe." The spell Greater Invisibility does not suffer this limitation.
So it depends: counterspelling will take down your Invisibility, but not Greater Invisibility. (Also note that Invisibility singles out foes as targets. I don't know if counterspelling an ally would cause you to lose invisibility!)