IN THE 13th and 14th centuries two celebrated male poets wrote about men in affectionate, even amorous, terms. They were Rumi and Hafiz, and both lived in what is now Iran. Their musings were neither new nor unusual. Centuries earlier Abu Nuwas, a bawdy poet from Baghdad, wrote lewd verses about same-sex desire. Such relative openness towards homosexual love used to be widespread in the Middle East. Khaled El-Rouayheb, an academic at Harvard University, explains that though sodomy was deemed a major sin by Muslim courts of law, other homosexual acts such as passionate kissing, fondling or lesbian sex were not. Homoerotic poetry was widely considered part of a “refined sensibility”, he says.

The modern Middle East views the subject very differently. A survey by Pew Research Centre in 2013 found that most people in the region believe homosexuality should be rejected: 97% in Jordan, 95% in Egypt and 80% in Lebanon. In 2007 Mahmoud Ahmadinejad, then the president of Iran, told a crowd of incredulous students at Columbia University in New York that “in Iran we don’t have homosexuals”. In 2001 the Egyptian Ministry of Culture burnt 6,000 volumes of Abu Nuwas’s poetry. What happened? The change can be traced to two factors. The first is the influence, directly or indirectly, of European powers in the region. In 1885 the British government introduced new penal codes that punished all homosexual behaviour. Of the more than 70 countries that criminalise homosexual acts today, over half are former British colonies. France introduced similar laws around the same time. After independence, only Jordan and Bahrain did away with such penalties. Combined with conservative interpretations of sharia law in local courts, this has made life tough for homosexuals. In some countries, such as Egypt, where homosexuality is not an explicit offence, vaguely worded “morality” laws are nevertheless widely used to persecute those who are accused of “promoting sexual deviancy” and the like. Second, the rise of Islamic fundamentalism in the 1980s coincided with that of the gay-rights movement in America and Europe, hardening cultural differences. Once homosexuality had become associated with the West, politicians were able to manipulate anti-LGBT feelings for their personal gain. Last year Hassan Nasrallah, the leader of Hezbollah, an Islamist political group based in Lebanon, accused the West of exporting homosexuality to the Islamic world, echoing Iran’s Ayatollah Khamenei’s warning a year before of “ravaging moral decay” from the West.

Increasingly conservative attitudes in the region have made matters worse. Since President Abdel Fattah al-Sisi’s regime came to power in Egypt in 2014, arrests of gay, lesbian and transgender people have risen fivefold in an apparent bid to stave off conservative critics. Homosexuality was made a capital offence in Iran after the Islamic revolution of 1979. Though executions for consensual same-sex activity are difficult to track, several gay men have been hanged on questionable grounds there, such as being accused of rape and not being given a fair trial, as recently as 2016. In Iraq, where same-sex activity is technically legal, the breakdown of order since 2003 has allowed Islamist militias and vigilantes to impose their own idea of justice. Groups such as Islamic State have become notorious for gruesomely murdering people suspected of being gay by throwing them off buildings and stoning them to death.

What could be done to improve matters? Some local activists say that campaigning for same-sex marriage and the like, as their counterparts in the West have done, is not helpful. Khalid Abdel-Hadi, the founder of My.Kali, a Jordanian gay-and-lesbian online magazine, says: “Our priority is not marriage...Our families see the stereotypical images of marriages and parades in the West and ask us ‘Is this what you want?’ ” Western-style activism may indeed attract dangerous attention: in May, Pride celebrations in Beirut were shut down and its organiser briefly arrested.

Yet grassroots campaigns and pressure from Western institutions do seem to have an effect. In Lebanon, between 2007 and 2017 four judges refused to criminalise homosexuality on the ground that the constitution, which punishes “unnatural sex” with up to one year in prison, does not apply to consensual same-sex relations. In 2014 Iraq accepted a United Nations recommendation to clamp down on discrimination, including on the ground of sexual orientation. Elsewhere campaigners have succeeded in getting the media to use the term mithli (homosexual) rather than “faggot” or “pervert”. And in all countries the internet, though heavily censored, provides people with an opportunity to find each other and talk about these issues. Ahwaa, a platform for LGBT people from Bahrain, boasts over 10,000 users. As more and more people communicate in this way, change will come.