Germany was the first country to employ submarines in war as substitutes for surface commerce raiders. At the outset of World War I, German U-boats, though numbering only 38, achieved notable successes against British warships; but because of the reactions of neutral powers (especially the United States) Germany hesitated before adopting unrestricted U-boat warfare against merchant ships. The decision to do so in February 1917 was largely responsible for the entry of the United States into the war. The U-boat campaign then became a race between German sinkings of merchant ships and the building of ships, mainly in the United States, to replace them. The Armistice terms of 1918 required Germany to surrender all its U-boats, and the Treaty of Versailles forbade it to possess them in the future.
In 1935, however, Hitler's Germany repudiated the treaty and forcefully negotiated the right to build U-boats. In 1941 the Germans, having acquired air and U-boat bases in Norway and western France, were able to reach far out into the Atlantic, and their U-boats began to operate in groups (called wolfpacks by the British). One U-boat would shadow a convoy and summon others by radio, and then the group would attack, generally on the surface at night. These tactics succeeded until radar came to the aid of the escorts and until convoys could be given continuous sea and air escort all the way across the Atlantic in both directions. In World War II Germany built 1,162 U-boats, of which 785 were destroyed and the remainder surrendered (or were scuttled to avoid surrender) at the capitulation. Of the 632 U-boats sunk at sea, Allied surface ships and shore-based aircraft accounted for the great majority (246 and 245 respectively).