The earliest known use of weapons specifically for the anti-aircraft role appears to have occurred during the Franco-Prussian War of 1870. After the disaster at Sedan Paris was besieged, and French troops outside the city started at attempt at resupply via balloon. Krupps quickly modified a 1-pounder (20mm) gun to be mounted on top of a horse-drawn carriage for the purposes of shooting down these balloons. Very little information on this weapon is published.
Given this early history, it is perhaps not surprising that it was only in Germany that development of anti-aircraft guns continued. In 1909 a number of Krupp's designs were shown, including adaptations of their 65mm 9-pounder, a 75mm 12-pounder, and even a 105mm gun. By the start of World War I the 75mm had become the standard German weapon, and came mounted on a large traverse that could be easily picked up on a wagon for movement.
Other countries involved seem to have largely ignored the possibility of aircraft being an important part of the hostilities, but this soon changed when German spotter aircraft started calling down increasingly accurate artillery fire.
All armies soon deployed a number of guns based on their smaller field pieces, notably the French 75mm and Russian 76.2, typically simply propped up on some sort of embankment to get the muzzle pointed skyward. The British Army decided on an entirely new weapon, and deployed a 3-inch gun that was perhaps the best of the bunch.
In general these ad-hoc solutions proved largely useless. With little experience in the role, and no ability to spot the "fall" of their rounds with accuracy, gunners proved unable to get the altitude correct and most fire fell well below their targets. The Krupp guns were later supplied with an optical sighting system and soon improved their capabilities, but these sorts of systems were not deployed by other forces.
As the aircraft started to be used in tactical roles against ground targets, these larger weapons proved too ponderous to aim at the quickly moving targets. Soon the forces were adding various machine gun based weapons mounted on poles, and the British also introduced another new weapon based on their 1-pounder "pom-pom" (a 20mm belt-fed gun). These short-range weapons proved more deadly, and the Red Baron arguably fell victim to an anti-aircraft Vickers gun.
When the war closed it was clear that the increasing capabilities of aircraft would require a much more serious attempt at downing them. Nevertheless the die was cast: anti-aircraft weapons would be based around heavy weapons attacking high-altitude targets, and on lighter weapons for use when they came to lower altitudes.
reconnaissance role. As the capabilities of aircraft improved, and more specificially, their engines, it was clear that their role in future combat would be even more critical.
Oddly enough, it was once again only the Germans that considered what to do about this. They developed a number of new anti-aircraft weapons in the early 1930s, including a new rapid-fire 20mm gun for low-altitude work, and a 37mm gun for low and medium altitudes. The 20mm was considered to be too low power against the increasingly fast planes, but instead of introducing a new gun, Krupps managed to squeeze four of the existing 20mm guns onto a single carriage of about the same weight.
Their high-altitude needs were originally going to be filled by an updated 75mm Krupps design, but the specifications were later ammended to require much higher performance. In response Krupps engineers (working at Bofors in Sweden) collaborated on a new 88mm design, the Flak 18[?]. The Flak 18 introduced a number of new features including a semi-automatic loading system, and a sectionized barrel and liner that allowed it to be easily replaced after wear.
The eighty-eight would go on to become one of the most famous artillery pieces in history. First used in Spain during the Spanish Civil War, the gun proved to be one of the best anti-aircraft guns in the world, as well as particularily deadly against tanks. It is in this later role that it became most widely known, the bane of allied tank crews everywhere.
By the end of the war the Germans had essentially given up on the 20mm as lacking punch. It was never cleanly replaced however; the 37mm was available in limited numbers, and a new dual-30mm system based on the MK 103[?] aircraft gun was never put into widespread use.
After the Dambusters raid in 1943 an entirely new system was developed that was required to knock down any aircraft with a single hit. The first attempt to produce such a system used a 50mm gun, but this proved unaccurate and a new 55mm gun replaced it. The system used a centralized control system including both search and targetting radar, which calculated the aim point for the guns after considering windage and ballisitics, the commands were then sent to the guns which used hydraulics to point themselves at high speeds. Operators simply fed the guns and selected the targets. This system, modern even by today's standards, was in late development when the war ended.
At the start of the war England had started a slow upgrade to their own systems, including a new 90mm gun in addition to their existing WWI-era 3" guns. Both were delivered with optical sighting systems for ranging. At the small-end of the scale a number of 20mm designs were used, but testing showed, as the Germans had discovered, that these weapons were of little use against modern aircraft.
Their solution was the introduction into service of 40mm guns based on the Bofors design. These had the power to knock down aircraft of any size, yet were light enough to be mobile and easily swung. The gun became so important to the British war effort that they even produced a movie, The Gun[?], in order to make workers on the assembly line work harder.
Service trials demonstrated another problem however, that the problem of ranging and tracking the new high-speed targets was almost impossible – at shorter ranges the "lead" required (aiming in front of the target because it is moving) is so small that it can be done manually, and at very long ranges the apparent speed is so slow that existing manual calculators were good enough. For the ranges and speeds that the Bofors worked at neither solution was good enough.
The solution was automation, in the form of a mechanical computer, the Kerrison Director. Operators kept it pointed at the target, and the Director then calculated the proper aim point automatically and displayed it as a pointer mounted on the gun. The gun operators simply followed the pointer and loaded the shells. The Kerrison was fairly simple, but it pointed the way to future generations which incorporated radar for ranging, and then tracking.
Post-war analysis demonstrated that even with newer anti-aircraft systems employed by both sides, the vast majority of bombers reached their targets successfully, on the order of 90%. This was bad enough during the war, but the introduction of the nuclear bomb into the equasion upset things considerably. Now even a single bomber reaching the target would be generally unacceptable.
The developments during WWII continued for a short time into the post-war period as well. In particular the US Army set up a huge air defense network around it's larger cities based on radar-guided 90mm and 120mm guns. But given the general lack of success of guns against even propeller bombers, it was clear that any defense was going to have to rely almost entirely on interceptor aircraft.
Things changed with the introduction of the guided missile. Although the Germans had been desperate to introduce them during the war, none were ready for service, and British countermeasures were likely to defeat them even if they were. With a few years of development however, these system quickly started to mature into practical weapons. The US started an upgrade of their defenses using the Nike Ajax missile, and soon the larger anti-aircraft guns disappeared.
The evolution since this time has been a slow change from guns to missiles for the shorter range roles. Originally missiles were useful only as a replacement for the very largest of anti-aircraft guns, but by the 1960s they had been scaled down to the point where they were also replacing smaller weapons previously serviced by guns in the 40 to 57mm range. Today man-portable missiles are generally replacing even the very smallest of gun systems.