Anti-submarine warfare (ASW) comprises the set of techniques, sensors, and weapons used to locate submarines and destroy them. The discipline emerged in the First World War, when submarines first became a significant military threat.
Until the development of nuclear propulsion, ASW was easier because submarines had to spend substantial time on the surface, where they could be spotted on radar or even visually. With the shift from blue-water Cold War operations to green-water operations in the littoral, even a diesel-electric submarine, much less one with non-nuclear air-independent propulsion, can quietly hide on the bottom for relatively long periods.
A phased approach to ASW, described below, uses modern technology, but the basic phases have been constant since the introduction of the submarine.
The major means of detecting submerged submarines are grouped as technologies of geophysical MASINT. Acoustic methods are the most basic, although a short-range method used primarily for localization, magnetic anomaly detection (MAD) can be useful.
Digital signal processing has had an enormous effect. Before computer assistance was available, passive sonar was useful only to give general warnings. Combining long, hull-mounted or towed microphone arrays with signal processing resulted in target motion analysis, often both providing detection and sufficient localization to use a guided weapon.
Recently, long-range active methods have been enabled. These can use high-power electronic sound generators, especially on specialized tracking platforms. Another approach, as seen with AN/SSQ-110 air-dropped sonobuoys, is to use small explosive charges to generate reflections from the target.
A number of techniques are in the research phase. Several of the techniques depend on detecting the effect, on the water surface, of the submarine's passage. Such devices, which are looking for a wake signature, include electro-optical MASINT either detecting bioluminescence, or a pattern of disturbance on the surface of the water.
Active sonar is the preferred localization technique. Modern guided torpedoes carry sonar, so they can be launched in the general area of a target and allowed to home in on it.
MAD is a supplementary method used by aircraft. It is short in range, but has the advantage that it can operate at the flight speed of an aircraft and do quick final localization.
An ASW force prosecutes a submarine once it has sufficiently accurate information on its position to take whatever action is appropriate. Prosecution is used rather than "kill" or a synonym, because the intention of the ASW force is not necessarily destruction of the submarine. The most basic reason the force would not want to use lethal weaponry is that the submarine is a friendly one, acting as the target for an ASW training exercise.
Next, the identity of the submarine may not be known. Friendly submarines often travel in "safe" lanes known only to their own side, but, in the Second World War, submarines in such lanes were still attacked and destroyed.
Submarines started with a combat edge in the First World War, sinking three cruisers, HMS Aboukir, Cressy and Hogue in the first mohths of the war. The inquiry after the sinking criticized the task unit leader for not calling for destroyers, but the weather was too bad for them to have operated — even if destroyers had effective ASW. The ships also did not steer zigzag courses to complicate torpedo solutions, a technique little used at the time.
Antisubmarine forces, at first, depended on visual sighting by ships, as well as minefields intended as much to restrict submarine movement as to destroy them. These were supplemented by kites and balloons, carrying a human observer, towed behind surface ships. The short range of the tow cables, however, gave an advantage to the submarine that sighted these devices in the air, telling it where the warship was located.
The first sensors were primitive acoustic devices: underwater microphones called hydrophones.
It was only the reintroduction of convoys that brought losses down to acceptable levels, one of the principal lessons learned from the First World War.
Early convoy tactics
Enter Operations Research
As a junior officer aboard the USS Cushing in 1953, "I found in the wardroom an old OEG (Operations Evaluation Group) publication, Anti-Submarine Warfare in World War II. The first half of the book was a narrative history of the Battle of the Atlantic with a lot of data in it. The second half of the book was about operations research techniques. I could see that some of those Operations Research techniques had been adopted in the tactical publications we were using; that just grabbed me. I really thought that it was the sort of thing that every naval officer who expected to fight should know. It was the essence of tactical thinking with a quantitative twist." 
Cold War Blue Water operations
Two destroyer classes, the Soviet Udaloys and U.S. Spruances, both were optimized for this environment, but proved to be insufficiently flexible. Some Udaloys remain in service, but, even though the Spruances also had a large vertical launch system for land attack, were found deficient in their area air defense capabilities.
Post Cold War and the Littoral
ASW in shallow littoral waters presents technical and political challenges quite different from the blue water operations characteristic of the Cold War. Where a towed array or other long-range sonar might make initial detection of a hostile submarine several convergence zones away (i.e., on the order of 150 km), and send helicopters for precise localizing, littoral targets will be closer than a first convergence zone.
Due to the amount of biologic noise, sound of water against a shallow bottom, etc., passive sonar is far less useful in the littoral than in open ocean. Some of the evolution includes adding active transmitters to the long arrays of surveillance vessels, making greater use of shipboard active sonar and helicopter dipping sonar, and remotely operated vehicles. Additional sensors, typically MASINT, may detect submarines by more exotic mechanisms, such as phosphorescence of marine life disturbed by underwater movement, changes in the structure of surface water waves, or even gravity disturbances by a dense submarine.
Defense against ballistic missile submarines
Fixed underwater submarine sensors are older than many realize. In WWI, there were magnetic detection loops in harbors, as early as 1914. A metal object passing over it, such as a submarine, will, even if degaussed, have enough magnetic properties to induce a current in the loop's cable.  In this case, the motion of the metal submarine across the indicating coil acts as an oscillator, producing electrical current.
Cold War systems combined multiple sensorsThe US installed massive Fixed Surveillance System (FSS, also known as SOSUS) hydrophone arrays on the ocean floor, to track Soviet and other submarines. SOSUS worked with sensors on warships and dedicated SURTASS) sensor carriers. Reducing the emphasis on Cold War blue-water operations put SOSUS decreased the role of SOSUS.
Maritime patrol aircraft
As with many ASW technologies, air search by fixed-wing aircraft is much older than commonly realized. Less than two years of the first aircraft takeoff from a vessel at sea, the cruiser USS Birmingham, the U.S. Navy started to investigate submarine spotting from airraft. "...under optimal environmental conditions, submarines could be detected visually at a depth of 30–40 feet from an altitude of 800 feet.  Air-launched antisubmarine [[torpedo]es did not exist, so their role was to alert warships of the target, and then attack with depth charges, general-purpose bombs, and a recoilless gun that could puncture the hull of a shallow submarine.
Just as the destroyer was developed to defend against fast coastal torpedo boats, it was logical that destroyers would take on defense against submerged torpedo-armed vessels. Destroyers were the main ASW vessel in WWI, with fairly primitive passive acoustic sensors. Many destroyers attacked because a surfaced submarine or a periscope had been visually sighted.
Destroyers of this period only had depth charges as ASW weapons. The goal, not infrequently, was not to kill the submarine underwater, but to force it to the surface for an unequal gun duel, or even being rammed.
Modern surface warships are most likely to use torpedo-carrying helicopters to engage submarines at a safe distance, complementing them with long-range sensors such as towed array sonars. Nevertheless, they may have their own homing torpedo launchers for final defense, final because the range of submarine torpedoes is greater than current surface- or air-launched ones. Alternatively, they may engage at a considerable distance with a rocket-lofted torpedo such as the RUM-139 Vertical Launch ASROC.
Specialized search vehicles
Smaller vessels such as submarine chasers and patrol craft often could do no more than detect a submarine, and perhaps make it break off an attack and evade.
A modern technique, however, is to use an unarmed, purpose-built vessel with extremely powerful acoustic sensors and signal processing. "Tuna boat" sensing vessels became SURTASS the primary blue-water long-range sensors SURTASS used longer, more sensitive towed passive acoustic arrays than could be deployed from maneuvering vessels, such as submarines and destroyers.
In one of the stranger byways of WWII, the first ASW helicopter carrier belonged to the Imperial Japanese Army.
In October 1943, the destroyer escort USS Rowell sank the USS Seawolf. A sister escort to Rowell had been torpedoed, Rowell established sonar contact with what her captain assumed to be the enemy that had just torpedoed a friendly ship. 
A special case is when the submarine's own weapons have a failure that causes them to attack the submarine that launched them. In WWII, circular torpedo runs sank USS Tullibee and USS Tang, and other submarines had near-misses. While there has never been an official public explanation of the sinking of the USS Scorpion, most theories suggest the incident was torpedo-related, with a malfunctioning torpedo either exploding onboard, or, after being jettisoned, made a circular run.
While the various Cold War sides have made vague allusions to hostile action, none has been proven. It is generally accepted that the Russian submarine Kursk was destroyed by an explosion in the torpedo room.
Countermeasures to ASW
In most circumstances, the first reaction of the captain of a submarine detecting a search in progress, or weapons fired against it, is to evade and break contact. While in WWII and earlier, submarines had guns that could be used while surfaced, a submarine was likely to be inferior to an ASW surface vessel or aircraft.
Modern submarine sensors are as good, or better, than those of most ASW platforms.
If forced to fight ASW forces, the submarine will use torpedoes; among the first guided torpedoes were German WWII models designed to home on escorts. A current controversy is whether to equip submarines with short-range surface-to-air missiles on a periscope mast or equivalent way to fire them while submerged; most navies believe that the chance of bringing down one aircraft is not worth confirming to the enemy that a submarine is present.
- Orloff, Lars R.H. (September 1999), Analysis of Fratricide in United States Naval Surface and Submarine Forces in the Second World War., U.S. Naval Postgraduate School, ADA374561
- Milford, Darren, Loss of HMS Aboukir, Cressy and Hogue
- Darin C. Curtis (April 2005), Lessons Forgotten: Royal Navy Anti-Submarine Tactics of World War, Air Command and Staff College, U.S. Air University
- English, Allan; Richard Gimblett & Lynn Mason et al. (31 January 2005), Command Styles in The Canadian Navy, Defence R&D Canada - Toronto, Contract Report CR 2005 - 096 p. 80
- Garrambone, Michael & Robert Sheldon (2004), "Interview of Wayne P. Hughes", Military Operations Research 9 (4) p. 31
- Richard Walding, What are Indicator Loops and how do they work?
- Pike, John (09 April 2002). Sound Surveillance System (SOSUS). GlobalSecurity.org.
- "Maritime Patrol Aviation: 90 Years of Continuing Innovation", Johns Hopkins APL (Applied Physics Laboratory) Technical Journal, 24 (3), 2003 p. 243
- Pike, John (09 April 2002). AN/UQQ-2 Surveillance Towed-Array Sensor System (SURTASS). GlobalSecurity.org.
- Orloff, p.32