An attack submarine or hunter-killer submarine is a submarine specifically designed for the purpose of attacking and sinking other submarines, surface combatants and merchant vessels. In the Soviet and Russian navies they were and are called "multi-purpose submarines". They are also used to protect friendly surface combatants and missile submarines. Some attack subs are also armed with cruise missiles, increasing the scope of their potential missions to include land targets.
Attack submarines may be either nuclear-powered or diesel-electric ("conventionally") powered. In the United States Navy naming system, and in the equivalent NATO system (STANAG 1166), nuclear-powered attack submarines are known as SSNs and their anti-submarine (ASW) diesel-electric predecessors were SSKs. In the US Navy, SSNs are unofficially called "fast attacks".
During World War II submarines that fulfilled the offensive surface attack role were termed fleet submarines in the U.S. Navy and "ocean-going", "long-patrol", "type 1" or "1st class" by continental European navies.
In the action of 9 February 1945, HMS Venturer sank U-864 while both were at periscope depth. This was the first and so far only intentional sinking of a submerged submarine by a submerged submarine. U-864 was snorkeling, thus producing much noise for Venturer's hydrophones (an early form of passive sonar) to detect, and Venturer was fortunate in having over 45 minutes to plot the U-boat's zig-zag course by observing the snorkel mast. Venturer's commander, James S. "Jimmy" Launders, was astute in assuming the U-boat would execute an "emergency deep" maneuver once it heard the torpedoes in the water, thus the "spread" of four torpedoes immediately available was aimed on that assumption. One hit, sinking the U-boat.
Following World War II, advanced German submarines, especially the Type XXI U-boat, became available to the Allies, particularly the United States Navy and the Soviet Navy. Initially, the Type XVII U-boat, with a Walter hydrogen peroxide-fueled gas turbine allowing high sustained underwater speed, was thought to be more developed than was actually the case, and was viewed as the submarine technology of the immediate future. However, the Type XXI, streamlined and with a high battery capacity for high submerged speed, was fully developed and became the basis for most non-nuclear submarine designs worldwide through the 1950s. In the US Navy, the Greater Underwater Propulsion Power Program (GUPPY) was developed to modernize World War II submarines along the lines of the Type XXI. By 1955 the U.S. Navy was using the term 'attack submarine' to describe the GUPPY conversions and the first postwar submarines (the Tang class and the Darter). 
It was realized that the Soviet Union had acquired Type XXI and other advanced U-boats and would soon be putting their own equivalents into production. In 1948 the US Navy prepared estimates of the number of anti-submarine warfare (ASW)-capable submarines that would be needed to counter the hundreds of advanced Soviet submarines that were expected to be in service by 1960. Two scenarios were considered: a reasonable scenario assuming the Soviets would build to their existing force level of about 360 submarines, and a "nightmare" scenario projecting that the Soviets could build submarines as fast as the Germans had built U-boats, with a force level of 2,000 submarines. The projected US SSK force levels for these scenarios were 250 for the former and 970 for the latter. Additional anti-surface (i.e., 'attack'), guided missile, and radar picket submarines would also be needed. By comparison, the total US submarine force at the end of World War II, excluding obsolescent training submarines, was just over 200 boats.
A small submarine suitable for mass production was designed to meet the SSK requirement. This resulted in the three submarines of the K-1 class (later named the Barracuda class), which entered service in 1951. At 750 long tons (760 t) surfaced, they were considerably smaller than the 1,650 long tons (1,680 t) boats produced in World War II. They were equipped with an advanced passive sonar, the bow-mounted BQR-4, but had only four torpedo tubes. Initially, a sonar located around the conning tower was considered, but tests showed that bow-mounted sonar was much less affected by the submarine's own noise.
While developing the purpose-built SSKs, consideration was given to converting World War II submarines into SSKs. The less-capable Gato class was chosen for this, as some of the deeper-diving Balao- and Tench-class boats were being upgraded as GUPPYs. Seven Gato-class boats were converted to SSKs in 1951–53. These had the bow-mounted BQR-4 sonar of the other SSKs, with four of the six bow torpedo tubes removed to make room for the sonar and its electronics. The four stern torpedo tubes were retained. Two diesel engines were removed, and the auxiliary machinery was relocated in their place and sound-isolated to reduce the submarine's own noise.
The Soviets took longer than anticipated to start producing new submarines in quantity. By 1952 only ten had entered service. However, production was soon ramped up. By the end of 1960 a total of 320 new Soviet submarines had been built (very close to the USN's 1948 low-end assumption), 215 of them were the Project 613 class (NATO Whiskey class), a smaller derivative of the Type XXI. Significantly, eight of the new submarines were nuclear-powered.
USS Nautilus, the world's first nuclear submarine, was operational in 1955; the Soviets followed this only three years later with their first Project 627 "Kit"-class SSN (NATO November class). Since a nuclear submarine could maintain a high speed at a deep depth indefinitely, conventional SSKs would be useless against them except in shallow water. As the development and deployment of nuclear submarines proceeded, in 1957–59 the US Navy's SSKs were decommissioned or redesignated and reassigned to other duties. It had become apparent that all nuclear submarines would have to perform ASW missions.
Research proceeded rapidly to maximize the potential of the nuclear submarine for the ASW and other missions. The US Navy developed a fully streamlined hull form and tested other technologies with the conventional USS Albacore, commissioned in 1953. The new hull form was first operationalized with the three conventional Barbel-class boats and the six nuclear Skipjack-class boats, when both classes entered service beginning in 1959. The Skipjack was declared the "world's fastest submarine" following trials, although the actual speed was kept secret.
Sonar research showed that a sonar sphere capable of three-dimensional operation, mounted at the very bow of a streamlined submarine, would increase detection performance. This was recommended by Project Nobska, a 1956 study ordered by Chief of Naval Operations Admiral Arleigh Burke. The one-off Tullibee in 1960 and the Thresher class starting in 1961 were the first with a bow-mounted sonar sphere; midships torpedo tubes angled outboard were fitted to make room for the sphere.
Tullibee was a type of nuclear-powered SSK; technologically very successful, intentionally slow but ultra-quiet with turbo-electric drive. Her unexpectedly high cost compared with the Thresher proved it was impossible to build a low-cost nuclear SSK (several nuclear reactor features could not be scaled down beyond a certain point, including radiation shielding). This result coupled with her lower performance was judged to be not cost-effective and the type was not repeated; the Navy decided to merge the hunter-killer role with the attack submarines, making the terms interchangible. Thresher was faster and had an increased diving depth, carried twice as many torpedoes, included comparable sound silencing improvements, and was commissioned only nine months later.
Thresher's loss in April 1963 triggered a major redesign of subsequent US submarines known as the SUBSAFE program. However, Thresher's general arrangement and concept were continued in all subsequent US Navy attack submarines.
Britain commissioned its first nuclear attack submarine HMS Dreadnought in 1963.
The first fully streamlined Soviet attack submarines were the Project 671 "Yorsh" class (NATO Victor I class), which first entered service in 1967.
China commissioned its first nuclear attack submarine Changzheng 1 in 1974, and France its first Rubis-class submarine in 1983.
The only time in history that a nuclear attack submarine engaged and sank an enemy warship was in the Falklands War, when on 2 May 1982 the British nuclear submarine HMS Conqueror torpedoed and sank the Argentine light cruiser ARA General Belgrano.
As of 2021 Brazil has a nuclear attack submarine under construction, India has finalized a nuclear attack submarine interim design, and Australia has started a nuclear attack submarine program under the AUKUS security pact with UK and US assistance.
Conventional attack submarines have however remained relevant throughout the nuclear era, with the British Oberon class and the Soviet Romeo, Foxtrot, Tango and Kilo classes being good examples which served during the Cold War. With the advent of air-independent propulsion technology, these submarines have grown more and more capable. Examples include the Type 212, Scorpène and Gotland classes of submarine. The US Navy leased HSwMS Gotland to perform the opposing force role during ASW exercises tactics. The Gotland caused a stir in 2005 when during training it "sank" the American carrier USS Ronald Reagan.