Prior to about 1890, naval weapons were only used against surface shipping. With the rise of the military submarine after this time, countermeasures were considered for use against them. The first submarine installation of torpedo tubes was in 1885 and the first ship was sunk by a submarine-launched torpedo in 1887. There were only two ways of countering the military submarine initially: ramming them or sinking them with gunfire. However, once they were submerged, they were largely immune until they had to surface again. By the start of the First World War there were nearly 300 submarines in service with another 80 in production.
World War I marked the first earnest conflict involving significant use of submarines and consequently marked the beginning of major efforts to counter that threat. In particular, the United Kingdom was desperate to defeat the U-Boat threat against British merchant shipping. When the bombs that it employed were found to be ineffective it began equipping its destroyers with simple depth charges that could be dropped into the water around a suspected submarine's location. During this period it was found that explosions of these charges were more efficient if the charges were set to explode below or above the submarine. However, many other techniques were used, including minefields, barrages and Q-ships and the use of cryptanalysis against intercepted radio messages. The airship ("blimp") was used to drop bombs but fixed-wing aircraft were mostly used for reconnaissance. However, the most effective countermeasure was the convoy. In 1918 U-boat losses became unbearably high. During the war a total of 178 U-boats were sunk, by the following causes:
British submarines operated in the Baltic, North Sea and Atlantic as well as the Mediterranean and Black Sea. Most of the losses were due to mines but two were torpedoed. French, Italian and Russian submarines were also destroyed.
Before the war ended, the need for forward-throwing weapons had been recognized by the British and trials began. Hydrophones had been developed and were becoming effective as detection and location devices. Also, aircraft and airships had flown with depth bombs (aerial depth charges), albeit quite small ones with poor explosives. In addition, the specialist hunter-killer submarine had appeared, HMS R-1.
The main developments in this period were in detection, with both active sonar (ASDIC) and radar becoming effective. The British integrated the sonar with fire control and weapons to form an integrated system for warships. Germany was banned from having a submarine fleet but began construction in secret during the 1930s. When war broke out it had 21 submarines at sea.