“P EOPLE ARE of two types in relation to you,” Imam Ali, the prophet Muhammad’s son-in-law and one of his first caliphs, or successors, is reputed to have said. “Either your brother in Islam, or your brother in humanity.” The Shia community of Mahfil Ali in north London tries to turn word into deed. Women often open services with a prayer. Sermons are in English. For the past decade the community has gone to the local church on Christmas Eve to attend midnight mass. Most ambitiously, it is turning its two-hut mosque into a £20m ($26m) Salaam (Peace) centre, complete with sports facilities, a restaurant, a theatre and a public library. There is talk of making a prayer space for Christians and Jews. “We want to nurture the community that nurtured us,” says a local leader.

Mosques in the West have come a long way since migrant workers rolled out plastic mats in their back rooms. A new generation of cathedral mosques has brought Islam out of Muslim districts into the public arena. Instead of traditional structures with inward-looking courtyards, their architects now design wide staircases that connect to the street. Sports facilities draw in younger Muslims who may have lost interest in the faith, as well as non-Muslims. The Islamic Centre of Greater Cincinnati, spread over 18 acres (seven hectares), is one of many in America that feels more like a country club than a mosque. Christian and Jewish teams compete in its basketball league.

Foreign organisations, Western governments and jihadists have all sought to speak for and mould Islam in the West, but the more established the faith becomes there, the less truck it wants with any of them. Of the three generations that have grown up since Muslims arrived in the West in the 20th century, the third is the most stridently opposed to government interference, be it foreign or Western, and to jihadist propaganda. As time passes, the old ties loosen. In most of the West, unlike in Muslim countries, no licence is currently needed to become an imam. Instead of a faith shaped from outside, millennial Muslims are creating something unprecedented: a do-it-yourself Islam.

That makes the religion frustratingly messy, but also diverse, dynamic and fluid. It is fragmenting into myriad interpretations, permutations and sects. Each by itself might be small, but collectively they are acquiring a critical mass that is pushing the faith’s boundaries. Western Islam covers the full spectrum of Islamic traditions, from the most conservative to the sort that considers Islam a culture but no longer a faith, and everything in between.

The four schools of Western Islam

To outsiders, the Salafist strand of the faith looks deeply traditional and unwelcoming. Its members wear Islamic dress and send their children to segregated Muslim schools. Boys in white tunics shiver in the cold. Teachers focus on scripture. But the Salafists insist that much of what they believe chimes with a Western approach to the faith. “Its appeal is like that of Protestant reformation in Christianity,” says Yasir Qadhi, America’s best-known preacher, who studied with Salafist masters. “It gives the individual direct connection to the text without going through a cleric or priest. It’s intellectually empowering.”

Though German officials, among others, have cut off dialogue, a new generation of Salafists is experimenting with greater openness. Searching for allies to stem secularism’s advance, Salafist imams engage in interfaith dialogue with like-minded conservatives of other faiths. The rapid influx of converts, too, has forced them to find ways to deal with their non-Muslim relatives. For role models, preachers look to the first Muslims in Mecca 1,400 years ago. They were also converts but kept their ties with their pagan families. And when they were persecuted, they embarked on the first hijra, or migration, and found refuge with the Christian rulers of Abyssinia. From his home in Memphis, Tennessee, Mr Qadhi plans to launch a new Islamic seminary later this year, staffed exclusively by Western lecturers. The teaching there, he says, will be “post-Salafist”, concentrating on the essentials. “While old-school Salafists are arguing over the minutiae of Islamic law, their children are debating whether or not God even exists,” he adds.

Western Islam is fragmenting into myriad interpretations

The second strand of the faith, political Islam, has long advocated engagement with non-Muslim society, not least to defend the interests of the umma, or Muslim community. Its main organisation, the Muslim Brotherhood, began as an armed anti-colonial movement in the Middle East. But chased into exile, its leaders have established a host of offshoots which profess loyalty to the West and praise its democratic systems (to the horror of the Muslim rulers they fled). It can be highly pragmatic. At a class at the Institut Européen des Sciences Humaines in Paris, Europe’s largest Muslim college and a bastion of Brotherhood orthodoxy, a female lecturer emphasises the flexibility of the sharia, or Islamic law, and its guiding principle of maslaha, or communal interest.

Another of the Brotherhood’s institutions, the Dublin-based European Council for Fatwa and Research, is rewriting orthodox precepts. Its jurists have approved mortgages, despite the Islamic prohibition on interest. They have ruled that female converts to Islam can keep their non-Muslim husbands. And some increasingly turn a blind eye to ways of life hitherto deemed deviant. “I’m not God. It’s his business. I don’t interfere,” says Taha Sabri, the imam of an Islamist mosque in Berlin.

If the Brotherhood gives Islam a Western hue, liberals, the third strand, give their Western lifestyles an Islamic one. For more than a generation, Bassam Tibi, a devout academic of Syrian origin at Göttingen university in Germany, has campaigned for “euro-Islam”, which by his definition is rooted in the principles of the Renaissance, Enlightenment and French Revolution. The faith, he says, has to adapt to its new environment, just as it did when it spread elsewhere in the world. “Africans made an African Islam and Indonesians made an Indonesian one,” he notes. “Islam is flexible and can be European.”

A few congregations of women-led mosques have surfaced in the West beyond the ivory towers of academia. Some are women-only, others mixed. Weekly prayers are often conducted on Sundays for members unable to leave work on Fridays. In 2008 Rabya Mueller, a former Catholic nun who converted to Islam, formed the Islamic Liberal Bund, modelled closely on liberal Judaism, and has begun leading prayers. Together with Lamya Kaddor, a German woman with a Syrian background, she is replacing Islam’s patriarchal baggage with gender equality and a commitment to gay rights. Much of their work, she says, involves marrying Muslims and non-Muslims of either gender. On Twitter, @queermuslims advertises prayer meetings for homosexual adherents of the faith. A training centre for gay imams has opened in France.

At the far end of the spectrum, a fourth strand wants to dispense with the religion altogether. In November six German academics, including one non-Muslim, formed the Secular Islam Initiative to promote “a folkloric relationship to Islam”, according to one of its founders, Hamed Abdel-Samad, the son of an Egyptian imam and author of a critical biography of the Prophet Muhammad. The organisation is still at the fledgling stage, but it may express the views of a surprising number of Muslims born in the West. According to a German government survey, only 20% of the country’s Muslims belong to a religious organisation. Many of the rest lead secular lives.

The number of lapsed Muslims in France is probably even higher than in Germany, particularly among descendants of north Africa’s Berbers, many of whom have long viewed Islam as a figleaf for Arabisation. Half the men of Algerian origin in France marry outside the faith, and 60% of those of Algerian parentage say they have no religious affiliation. In America the Pew Research Centre estimates that 23% of Muslims no longer identify with the faith. “We’re facing the same problem of assimilation as the Jews,” says an imam in Dearborn, Michigan.

Thinking the unthinkable

Mosques seeking to rejuvenate their flock are having to adapt to changing sexual practices, too. Half of America’s Muslim students, male and female, admit to having had premarital sex, according to a study in 2014. “When I began teaching in 2003, no girl would admit to having a boyfriend,” says Ms Kaddor, who until recently taught religious studies for Muslims in a Rhineland school. “Now, some openly say they’re bisexual.” Muslim dating apps abound. “Find a beautiful Arab or Muslim girl on muzmatch,” promises one that claims a million users, complete with an optional chaperone feature.

Women are also increasingly demanding a say, not least because they are now typically better educated than men. The number of women on mosque boards is still small but growing, even in orthodox communities. Inside the prayer hall, women, originally confined to the gallery, are moving to the back of the ground floor and sometimes down the sides. In many Black American mosques men and women share the same hall. Prejudice against homosexuality remains strong but is retreating. Among British Muslims over 65, 76% want to ban the practice; for those aged 18-24, the proportion is 40%.

Adherents of all four strands often change allegiance. Mr Abdel-Samad was briefly a Muslim Brother before converting to secularism. Many Salafist preachers were nominal Christians who trod the path in reverse. Such cross-fertilisation does not always breed understanding. Imams deviating from orthodoxy risk expulsion from their mosques. Abdel Adhim Kamouss, a Salafist preacher in Berlin, has been ousted from two mosques for asserting that the Prophet did not condemn homosexuality or shaking hands with women. Mr Kamouss is one of several people interviewed for this report to receive a fatwa sentencing him to death for apostasy. In the suburbs of some British cities Muslim shopkeepers are forced to close before Friday prayers. And women can still become victims of honour crimes in conservative enclaves such as Dewsbury in northern England.

Optimists say such violence is a sign of desperation. In France the last known honour crime was committed two decades ago. Across the West Muslims turn out to vote in greater numbers than the rest of the population and increasingly interact with non-Muslims. For many of the younger ones, divisions of sect, ethnicity and religious observance are less and less relevant. In short, given a range of choices, Muslims in the West increasingly see Islam more as a matter of personal choice than a creed guided by government, whether at home or abroad. “The younger generation has won the battle,” says Olivier Roy, a French author on Islam in the West.

Arab governments sometimes berate their Western counterparts for not doing enough to curb extremism, by which they often mean curbing their exiled dissidents. In fact, Western governments do monitor hate speech and support for terrorism. But viewing Islam primarily through a security prism distorts relations between Muslims and non-Muslims in the West.

Religious leaders are seeking to bridge divides

Muslim inclusion in local decision-making can break down prejudice but often faces resistance from communities. Jennifer Eggert, a Muslim expert on terrorism, tours London mosques arguing for Muslims to play a bigger part in countering terrorism. The New York Police Department overcame communal mistrust by creating a Muslim Officers Society, the first in America. This has helped increase police recruitment among Muslims from fewer than a dozen in 2001 to over 1,000, says its founder, Adeel Rana. The inauguration last month of America’s first two Muslim congresswomen may also help normalise Muslim participation at all levels of society.

Integrating Islam more into national histories could play a part, too. In some British mosques imams pinned poppies on each other to mark the centennial of the first world war and remember the hundreds of thousands of Muslims killed in battle. But their sacrifice is rarely commemorated at national level, contributing to the feeling that Muslims remain outsiders. Now “we are creating a generation not of foreign fighters but of foreign citizens,” says Khalid Chaouki, a former MP in Italy’s parliament who runs the country’s largest mosque in Rome.

Cultural programmes, too, can cross communal boundaries. When the Benaki Museum in Athens began offering school tours of its Islamic art collection, an MP accused it of spreading the culture of terror. A decade on, the museum has expanded the programme to include interactive tours of life in Ottoman Athens. “We’re filling a big gap in our history that most schools skip over,” says Maria-Christina Yannoulatou, the head of the museum’s education department, referring to 450 years of Muslim rule that Greece omits from its curriculum. “We want to challenge taboos and show the ordinary lives that heroic histories obscure.”

Religious leaders are also seeking to bridge divides. Many priests work hard to counter far-right narratives, accusing anti-immigrant politicians of betraying Christian ethics. Many churches double as sanctuaries for refugees. Some synagogues as well as churches in America host Muslim Friday prayers for congregations lacking a space to worship. In the same vein, after a right-wing gunmen fired on a Pittsburgh synagogue in October, Muslims packed the vigils, sent tweets of condolence and spoke at events on anti-Semitism. In Germany’s election in 2017 church-going voters were three times less likely to vote for the far-right A f D party than secular ones.

Having settled in the West for the third time in history, this time in a different role, Islam seems destined to stay. The journey so far has not been easy. But a third generation of Muslims now seems set to become a permanent part of a more diverse, more tolerant Western society—as long as that society continues to nurture those virtues.