A submachine gun or SMG is a select-fire weapon, either handheld (machine pistols) or shoulder-fired, that fires pistol-caliber rounds. Its primary role was that of a close-quarters weapon; it has since been replaced by short-barreled rifles (carbines) for this purpose.
The concept of the submachine gun dates back to World War One; the trench warfare of this period required effective, compact weapons for close combat in trenches; additionally, a lightweight and maneuverable fully automatic weapon was desirable to complement light machine guns in both defensive and offensive scenarios.
The submachine gun was once used as a CQC (close-quarters combat) weapon, usually in house and room clearings (owing to their usually compact size). Due to the fact that pistol calibers are poor terminal performers and carbines packed much more power in a similarly sized package, most law enforcement agencies, as well as the military, became increasingly reliant on the carbine to take over the role of the SMG.
However, the submachine gun still holds one advantage: when fired suppressed, the SMG is quieter than a carbine.