The Muslim world acquired the gunpowder formula some time after 1240, but before 1280, by which time Hasan al-Rammah had written, in Arabic, recipes for gunpowder, instructions for the purification of saltpeter, and descriptions of gunpowder incendiaries. Early Muslim sources suggest that knowledge of gunpowder was acquired from China and may have been introduced by invading Mongols. This is implied by al-Rammahs usage of "terms that suggested he derived his knowledge from Chinese sources." Early Arab texts on gunpowder refer to saltpeter as "Chinese snow" ( ), fireworks as "Chinese flowers" and rockets as "Chinese arrows" (sahm al-Khitai'). Similarly, the Persians called saltpeter "Chinese salt" or "salt from Chinese salt marshes" ( ). Fireworks listed by al-Rammah include "wheels of China" and "flowers of China".
The gunpowder formula of al-Rammah has a saltpeter content of 68% to 75%, which is more explosive than is necessary for rockets, however no explosives are mentioned. Al-Rammahs text, The Book of Military Horsemanship and Ingenious War Devices (Kitab al-Furusiya wal-Munasab al-Harbiya), does however mention fuses, incendiary bombs, naphtha pots, fire lances, and an illustration and description of the earliest torpedo. The torpedo was called the "egg which moves itself and burns." Two iron sheets were fastened together and tightened using felt. The flattened pear shaped vessel was filled with gunpowder, metal filings, "good mixtures," two rods, and a large rocket for propulsion. Judging by the illustration, it was evidently supposed to glide across the water.
Hasan al-Rammah was the first Muslim to describe the purification of saltpeter using the chemical processes of solution and crystallization. This was the first clear method for the purification of saltpeter.
According to Joseph Needham, fire lances were used in battles between the Muslims and Mongols in 1299 and 1303.
The earliest surviving documentary evidence for cannons in the Islamic world is from an Arabic manuscript dated to the early 14th century. The authors name is uncertain but may have been Shams al-Din Muhammad, who died in 1350. Dating from around 1320–1350, the illustrations show gunpowder weapons such as gunpowder arrows, bombs, fire tubes, and fire lances or proto-guns. The manuscript describes a type of gunpowder weapon called a midfa which uses gunpowder to shoot projectiles out of a tube at the end of a stock. Some consider this to be a cannon while others do not. The problem with identifying cannons in early 14th century Arabic texts is the term midfa, which appears from 1342 to 1352 but cannot be proven to be true hand-guns or bombards. Contemporary accounts of a metal-barrel cannon in the Islamic world do not occur until 1365. Needham believes that in its original form the term midfa' refers to the tube or cylinder of a naphtha projector (flamethrower), then after the invention of gunpowder it meant the tube of fire lances, and eventually it applied to the cylinder of hand-gun and cannon.
According to Paul E. J. Hammer, the Mamluks certainly used cannons by 1342. According to J. Lavin, cannons were used by Moors at the siege of Algeciras in 1343. A metal cannon firing an iron ball was described by Shihab al-Din Abu al-Abbas al-Qalqashandi between 1365 and 1376.