A submachine gun is a firearm which combines the automatic fire of a machine gun with the ammunition of a pistol, and is usually between the two in weight and size. They were first experimented with in the form of stocked pistols being turned fully automatic in the late 1800s and early 1900s.
The first dedicated designs were developed in the latter stages of WWI both as improvement on earlier stocked pistols, and to offer an advantage in trench warfare. They rose to prominence as a front-line and commando weapon during WWII, and are now widely used by police and paramilitary organizations. They are ideal for close-range combat in enclosed urban environments, where a weapon's range and accuracy is less important than the ability to easily and instinctively spray a target with bullets. They were also popularized in the 1920's and 30's as weapon of choice of gangsters. Submachine guns lack long-range power and accuracy, limiting their use in the open.