Afarit appear already in early poems, such as those of Al-Maʿarri (973 – May 1057), who describes his protagonist visiting a paradise with "narrow straits" and "dark valleys" for afarit, between heaven and hell. In later works, the afarait are mentioned among the narratives collected in "One Thousand and One Nights". In one tale called "The Porter and the Young Girls", a prince is attacked by pirates and takes refuge with a woodcutter. The prince finds an underground chamber in the forest leading to a beautiful woman who has been kidnapped by an ifrit. The prince sleeps with the woman and both are attacked by the jealous ifrit, who changes the prince into an ape. Later a princess restores the prince and fights a pitched battle with the ifrit, who changes shape into various animals, fruit, and fire until being reduced to cinders. In "The Fisherman and the Jinni" an ifrit, locked in a jar by the Seal of Solomon, is released but later tricked by the fisherman again into the jar. Under the condition that the ifrit aids him to achieve riches, he releases the ifrit again. The latter ifrit however, might be substituted by a marid, another type of powerful demon easily tricked by the protagonist. The latter portrayal of an ifrit, as a wish-granting spirit released from a jar, became characteristic of Western depictions of jinn.