The short definition: counterbattery fire is using your guns to shoot at their guns so their guns can't shoot at you.
Not all that helpful, I know.
NATO document AAP-6, "NATO Glossary of Terms and Definitions", defines counterbattery fire as follows:
Fire delivered for the purpose of destroying or neutralizing the enemy's fire support system. Note: Counterbattery fire can be either proactive or reactive.
Long ago, mankind developed weapons of war whose effects ranged beyond the reach of the human arm. Mankind being mankind, these weapons were subject to much tinkering, and their range and power increased steadily. Starting with the humble sling or atlatl, projectile weapons moved up to the bow in its various forms, and then made the jump to siege engines beyond human carrying power. The ballista, trebuchet and catapult are perhaps the most famous. Cannon arrived, and with them a proliferation of types of powder weapons - the cannon, the howitzer, the mortar and so forth.
What these larger projectile weapons produced was the concept of indirect fire. When your weapon can throw its projectile several hundred meters, the first thing you worry about is that the enemy has their own version which can throw nastiness right back. At that point, the practical side of the Lanchester laws kicks in, and the users of these weapons start wanting very badly to ensure that anyone firing at them has trouble aiming.
Thus, indirect fire. In sum, you hide your weapon out of sight of the enemy, and you use whatever means of intelligence are available (scouts, spies, maps, observers, etc.) to aim them. If you're lucky, you can prevent the enemy from doing the same to you - and you can rain destruction on them from a safe place.
Of course, the enemy doesn't want you do be able to do this. And thus, immediately after indirect fire came into being (quite likely on the order of several minutes later) counterbattery fire was invented. Essentially, counterbattery fire is a method for preventing the enemy's indirect fire weapons from harming you (or at least, reducing their effects) by using your own indirect fire weapons on them. Counterbattery fire, then, is just like regular indirect fire - but which is specifically aimed at the enemy's own indirect fire weapons.
In practice, counterbattery fire as an independent technique really came into its own during World War I, where large-scale artillery duels - on the scale of entire sectors, sometimes - were common. Both sides tried to evolve their way out of the trench warfare trap they found themselves in on the Western Front, and the artillery forces were no exception.
Counter-battery fire includes all phases of the activity. At the outset, there is target acquisition - you first have to figure out where the guns you're shooting at are. There is a myriad of inputs which fall under this phase, from direct observation (scouts, observers) to reconnaissance reports or imagery from satellites, UAVs or manned craft, to high-tech battlefield systems in modern times such as counterbattery radar, sound detection, seismic measurements and more.
Once you have information from these sources, it must be collected, collated and analyzed. This is generally referred to as 'intelligence' when describing battlefield operations. This would include not only integrating the reports, but checking them against other sources of information available such as enemy order of battle or current friendly movement orders (you want to be sure, after all, the gun you've found is an enemy gun and not one belonging to a friendly unit, right?).
Intelligence should produce a target set - a big list of coordinates to attack, ideally with information on what type of target is at each (buried? Armored? mobile? etc.) and a priority. This is then handed off to the organization or unit that will actually perform the fire action, and is generally referred to as 'fire control.' In this step, the target set is matched with available firing units, ammunition and scheduling, and individual orders (called 'fires') are passed to the shooters. At that point, the final link in the chain, the shooters themselves, carry out the fire mission.
Of course, sometimes these functions are combined or left out depending on the type of counterbattery fire underway. A mortar unit with its own counterbattery radar may, in fact, end up performing all of those functions itself in the interests of speed and accuracy.