THERE is a cleft in a stone hill outside Qardho, in northern Somalia, which even the hardest gunmen and frankincense merchants avoid. In the cool dark, out of the bleached sunshine, there is a pit, a kind of Alice in Wonderland rabbit hole, which is said to swirl down into the world of jinn. Locals say jinn—genies, that is—fade in and out above the pit. Sometimes they shift into forms of ostriches and run out over the desert scrub.

The Bible holds that God created angels and then made man in his own image. The Koran states that Allah fashioned angels from light and then made jinn from smokeless fire. Man was formed later, out of clay. Jinn disappointed Allah, not least by climbing to the highest vaults of the sky and eavesdropping on the angels. Yet Allah did not annihilate them. No flood closed over their heads. Jinn were willed into existence, like man, to worship Allah and were preserved on earth for that purpose, living in a parallel world, set at such an angle that jinn can see men, but men cannot see jinn.

Less educated Muslims remain fearful of jinn. Hardly a week passes in the Muslim world without a strange story concerning them. Often the tales are foolish and melancholy. In August, for instance, Muslims in the Kikandwa district of central Uganda grew feverish over reports of jinn haunting and raping women in the district. So when a young woman stumbled out of the forest one day, unkempt and deranged, she was denounced as a jinn. Villagers beat her almost to death. Police finished the job with six bullets at close range. The young woman called out for her children in her last moments. An investigation revealed her to be from a neighbouring district. She had spent days without food or water, searching for her missing husband. Editorials in Ugandan newspapers called on the government formally to deny the existence of jinn.

That would be divisive. Although a few Islamic scholars have over the ages denied the existence of jinn, the consensus is that good Muslims should believe in them. Some Islamic jurists consider marriage between jinn and humans to be lawful. There is a similar provision for the inheritance of jinn property. Sex during menstruation is an invitation to jinn and can result in a woman bearing a jinn child. According to the Koran, the Prophet Muhammad preached to bands of jinn. Some converted to Islam. This is how jinn describe their condition in the Koran:

And among us [jinn] there are righteous folk and among us there are those far from that. We are sects, having different rules. And we know that we cannot escape from Allah in the earth, nor can we escape by flight. And when we heard the guidance [of the Koran], we believed therein, and who so believeth in his Lord, he feareth neither loss nor oppression. And there are among us some who have surrendered to Allah and there are among us some who are unjust.

In Somalia and Afghanistan clerics matter-of-factly described to your correspondent the range of jinn they had encountered, from the saintly to the demonic; those that can fly, those that crawl, plodding jinn, invisible jinn, gul with vampiric tendencies (from which the English word ghoul is taken), and shape-shifters recognisable in human form because their feet are turned backwards. Occasionally the clerics fell into a trance. Afterwards they claimed their apparently bare rooms had filled with jinn seeking favours or release from amulet charms.

A parallel universe

Although Somalia and Afghanistan have different religious traditions (Somalia being more relaxed), jinn belief is strong in both countries. War-ravaged, with similarly rudimentary education systems, both have a tradition of shrines venerating local saints where women can pray. Women are supposed to be more open to jinn, particularly illiterate rural women: by some accounts education is a noise, a roaring of thought, which jinn cannot bear. Sometimes women turn supposed jinn possession to their own advantage and become fortune-tellers. Among the most popular questions asked of such women is: “Will my husband take a second wife?” The shrines are often little more than a carved niche in a rock, with colourful prayer flags tied to nearby trees. Jinn are said to be attracted to the ancient geography of shrines, many of which predate Islam; as some have it, the shrines were attracted to the jinn.

Islam teaches that jinn resemble men in many ways: they have free will, are mortal, face judgment and fill hell together. Jinn and men marry, have children, eat, play, sleep and husband their own animals. Islamic scholars are in disagreement over whether jinn are physical or insubstantial in their bodies. Some clerics have described jinn as bestial, giant, hideous, hairy, ursine. Supposed yeti sightings in Pakistan's Chitral are believed by locals to be of jinn. These kinds of jinn can be killed with date or plum stones fired from a sling.

Hardly a week passes in the Muslim world without a strange story concerning them. Often the tales are foolish and melancholy

But to more scholarly clerics jinn are little more than an energy, a pulse form of quantum physics perhaps, alive at the margins of sleep or madness, and more often in the whispering of a single unwelcome thought. An extension of this electric description of jinn is that they are not beings at all but thoughts that were in the world before the existence of man. Jinn reflect the sensibilities of those imagining them, just as in Assyrian times they were taken to be the spirits responsible for manias, who melted into the light at dawn.

When a donkey brays

The English word genie, from an unrelated French root, is now too soft and gooey with Disney's Aladdin to catch the acid qualities attributed to jinn. Sepideh Azarbaijani-Moghaddam, a specialist on Afghanistan who has undertaken anthropological research on jinn belief, reckons she may once have been in the presence of jinn. She was riding with others in the Afghan province of Badakhshan. It was towards dusk. They came down into a valley forested at the bottom. The horses tensed. “Suddenly from out of the trees I felt myself being watched by non-human entities.” A cold fear overcame her, “the fear of losing the faculty of reason”. A Kabul cleric describes this sort of feeling as a shock at the existence of otherness. Animals sense it also: when a donkey brays, it is said to be seeing a jinn.

Unbelieving jinn, those who resisted the Koran, are shaytan, demons, “firewood for hell”. Many Muslims see the devil as a jinn. Some reckon the snake in the Garden of Eden was a shape-shifting jinn. All this may yet play a part in the war on terrorism. Factions in Somalia and Afghanistan have accused their enemies of being backed not only by the CIA but by malevolent jinn. One theory in Afghanistan holds that the mujahideen, “two-legged wolves”, scared the jinn out into the world, causing disharmony. It is jinn, they say, who whisper into the ears of suicide-bombers.

Sheikh Mubarak Ali Gilani, a Pakistani cleric connected with a jihadist group, Jamaat al-Fuqra, has given warning to America that its missiles will be misdirected by jinn. It was all very different in the days of King Solomon, who was said to have had control over jinn and used them as masons in building the temple in Jerusalem. The Jewish influence over jinn is strong. It is probably no coincidence that the inscription on Aladdin's lamp, which bound the jinn, was engraved with Hebraic characters. Believers in abduction by aliens like to think jinn are aliens; some of the more confrontational Muslim clerics dismiss claimed apparations of the Virgin Mary as the work of jinn.

The jinn demanded a cigarette, then another, and then it became impatient and swallowed lighted cigarettes whole

The story of Ahmed Shah Masoud, the commander of Afghanistan's Northern Alliance, clearly shows up the link between jinn and myth-making. Masoud resisted the Soviet Union and the Taliban from his base in the Panjshir valley until he was assassinated by al-Qaeda operatives on September 9th 2001. According to local legend, Muslim jinn were on his side. One of his fighters was said to have slain a dragon in a mountain lake during the Soviet occupation and to have brought the dragon's jewel to Masoud, with the help of Muslim jinn. In murdering Masoud, some Panjshiris say, Osama bin Laden declared war on Muslim jinn also. This is obvious, they say, from Mr bin Laden's insistence on division and violence.

Your correspondent spent a night with Masoud's former bodyguards in the Panjshir. The men were employed to look after Masoud's tomb. His office was locked. The bodyguards sat cross-legged on the floor of a room opposite. A kerosene lantern flickered. Machineguns were propped against the bed-rolls. A few men went outside. The first winter snow was falling on the jagged peaks that towered up on all sides. It was fiercely cold. A dog limped below, ears flat, tail between its legs. It whimpered. The men looked at the dog. “The jinn is still here,” one said. “Bismillah,” responded the others. They pointed out jinn settlements just below the snow-line on the mountain slopes. Inside, over plates of mutton and grey rice, tea, snuff and Korean cigarettes, they told the story of how the cook had been possessed by a jinn the week before. He was a devout man, they said, a non-smoker and illiterate. “He fell ill. When he recovered, he found he could speak and write in many languages. The jinn that was in him was well-travelled but also pushy. It demanded a cigarette, then another, and then it became impatient and swallowed lighted cigarettes whole.”

In Somalia, the port of Bossaso is famous for its sorcerers. Some of its ruling class claim to have intermarried with jinn long ago. On a recent visit your correspondent was taken to a metal shed at the edge of a slum where jinn were supposed to be banished from taking human form. The air inside the shed was thick with frankincense. There was a man cloaked in red cloth kneeling on the ground. A jinn was in him, a sorceress running the ceremony said, and indeed the man wore an eerie expression, as though a part of him was obscured. Young men jumped up and down around him, chanting and beating drums. The gunmen accompanying your correspondent were too scared to step into the shed. Later, walking away from the shed in hot sunshine, one of the gunmen insisted that he could see a jinn scavenging for bones in the dirt. There did not appear to be anything there.