A submachine gun (SMG) is an automatic carbine, designed to fire pistol cartridges. It combines the automatic fire of a machine gun with the cartridge of a pistol. The submachine gun was invented during World War I (1914–1918), but the apex of its use was during World War II (1939–1945) when millions of the weapon type were manufactured. Today the submachine gun has mostly been replaced by the assault rifle for military use. (The assault rifle uses an intermediate-power cartridge with more power than a pistol but less than a standard rifle or battle rifle.)

In the early 20th century, experiments were made by converting stocked pistols from semi to fully automatic. Stocked automatic weapons firing pistol rounds were developed around the same time during World War I, by Italy, Germany, and the United States. The first dedicated designs were developed in the latter stages of World War I both as improvements on earlier stocked pistols, and to offer an advantage in trench warfare. They were popularized in the 1920s and 1930s as weapon of choice of American gangsters and police, in the form of the famous Thompson submachine gun, commonly referred to as the "Tommy Gun". Submachine guns rose to prominence as a front line close-quarters combat weapon and commando firearm during World War II. They are now widely used by police SWAT, military commando, paramilitary, and counter-terrorism team members for a variety of situations. Submachine guns are highly effective in close quarters; their lower-powered pistol cartridges make them generally more controllable in fully automatic fire compared to assault rifles, while their small size and light weight grant maneuverability. However, pistol cartridges generally have low effectiveness against targets protected by body armor or cover, and are short-ranged compared to intermediate and rifle cartridges.