Sectarian and ethnic cleansing by all sides in Syria and Iraq is becoming more intense, ensuring that there are few mixed areas left in the two countries and, even if the war ends, many refugees will find it too dangerous to return to their homes.

Communities which once lived together in peace are today so frightened of each other after years of savage warfare that the more powerful sect or ethnic group is forcing out the weaker one. This pattern is repeating itself everywhere from the Sunni towns captured by Shia militiamen in provinces around Baghdad to Christian enclaves in central Syria under threat from Isis, and in Turkmen villages just south of the Syrian-Turkish border being bombed by Russian aircraft.

The inability of Syrians and Iraqis to return home in safety means that Europe and the Middle East will have to cope for decades to come with an irreversible refugee crisis brought on by the war.

There are good reasons for everybody to be afraid, though outside powers play down the sectarian or ethnic agenda of their local Syrian proxies and allies. “We will end up like the Christians, being forced out of the country,” says a young Sunni photographer, Mahmoud Omar, who once lived in Ramadi in the overwhelmingly Sunni province of Anbar. Many fled when Isis captured the city in May which is now under assault by the military forces of the Shia-dominated government in Baghdad trying to recapture it. Some 1.4 million people from Anbar or 43 per cent of its population are displaced, according to the International Organisation for Migration.

The Sunni Arab tribes in Raqqa province in Syria issued a statement earlier this month accusing Kurdish forces, the People’s Protection Units (YPG), of displacing Arabs from the Tal Abyad town on the border crossing with Turkey. It says that “no YPG fighter can enter the Arab areas where our fighters are present”. The YPG denies that it has forced Arabs to leave Tal Abyad, but Syrian Kurds often see Sunni Arabs as Isis collaborators.

Smaller communities such as the Christians in Iraq and Syria are being eliminated. In the village of Sadad, once a home to 5,000 Syriac Orthodox Christians off the highway linking Damascus and Homs, people are leaving because there is only a few hours of electricity a day and prices are very high, but above all because villagers are terrified of being slaughtered by Isis. Two years ago extreme Sunni jihadis, this time led by the al-Qaeda affiliate Jabhat al-Nusra, captured Sadad and held it for 10 days, killing 45 Christians and destroying or looting 14 churches before being driven out by the Syrian army.

In Syria many of the estimated 5.3 million refugees and 6.5 million internally displaced people are likely to find that their houses and neighbourhoods have been destroyed or permanently occupied by well-armed members of a hostile community.

The same is true in Iraq. Describing Sunni villages south of Kirkuk whose inhabitants have been driven out by Shia and Kurds, a human rights specialist, who wished to remain anonymous, said “if the Sunni flee then people say it is proof they were working with Isis and, if they stay, they are members of Isis sleeper cells who are waiting to strike. They can’t win either way.” Fear of “sleeper cells” is pervasive in both Iraq and Syria.

The mass flight and expulsion taking place is on the scale of that in India and Pakistan at the time of Partition in 1947 or in Germany at the end of the Second World War. “Efforts at local ethnic cleansing are already making Syria’s de facto partition more and more irremediable,” says Professor Fabrice Balanche of the Washington Institute for Near East Policy in a study called Ethnic Cleansing Threatens Syria’s Unity. He adds that “sectarian diversity is disappearing in many areas of the country”.

The takeover of a whole area by a single sect, ethnic group or political affiliation tends to be difficult to reverse because houses are distributed to new owners who do not want to give them up.

The Sunni Arabs have been at the heart of the uprising against President Bashar al-Assad since 2011 and likewise see non-Sunni communities as supporters of Assad, and hence the targeting of Sunni districts by government artillery and bombing. Whole districts of Damascus and Homs once under rebel control are today a sea of ruins with every building shattered by explosives. But the Sunni community is also split, often along social lines, with the better-off and better-educated siding with Assad against the poorer, more rural and tribal Sunnis.

Mercy is scarce in the war in Syria and Iraq. Shia in Iraq say that since 2003 Isis and its al-Qaeda-type predecessors have systematically targeted Shia mosques, marketplaces, bus queues and pilgrimages, killing thousands of civilians. When Isis took northern and western Iraq last year its fighters filmed themselves executing 1,700 young Shia military recruits near Tikrit. Last August Isis raped, murdered and enslaved members of the Yazidi minority. Captured Syrian soldiers were ritually decapitated. In June an Isis suicide squad killed 220 Syrian Kurdish men, women and children in Kobani.