In Arabian mythology, a genie or djinn is a type of spirit. In Pre-Islamic thought, it had magical powers and was sometimes, though not always, wicked, or at least mischievous. In Islam, the genie has become more analogous to a demon, with the Devil as the most powerful of these spirit, while in Western culture, it is typically portrayed as a magical spirit with no religious connotations who is capable of granting wishes. The English word comes from the French for "spirit," which was used to translate djinn in the first French translations of the Arabian Nights.
The Western concept is drawn mainly from the tale of Aladdin in the Arabian Nights, in which Aladdin frees a genie from his imprisonment in a lamp and is granted wishes in return. A wider reading of the Arabian Nights reveals the spirit as a creature quite different from the modern Western version, however. There are different types with different sets of magical powers, and in some mythology, they are categorized by the element — fire, water, earth, or air — that governs them. Some types of genies are frightening, such as the ghul, which lends its name to the Modern English ghoul, and the succubus-like female versions.
In Islam, genies are believed to live among humans but to be invisible for the most part. They are said to have free will, like humans but unlike angels, and to have the capacity for good or evil. There are references to them throughout the Qur'an, and the Devil, called Shaitan in Islam, is the most powerful of these spirits. Evil ones are similar to demons in Christian thought and can possess people physically or tempt them into sin.
Though the genie in Western culture is usually benign, it is often mischievous and sometimes borders on the more frightening versions from the Middle East. Dangerous ones in the West often work by distorting the wishes of those they are supposed to serve or by taking their words very literally. This trope in Western folklore predates the arrival of the genie in Western consciousness and is summarized in the adage, "Be careful what you wish for."