Tens of thousands from Iraq’s minority Yazidi community have fled their homes after Sunni militants captured their towns in the latest offensive to expand the territory of their self-styled caliphate.

As Kurdish fighters struggled to hold back the onslaught of the Islamic State militants on Iraq’s north, some 40,000 Yazidis, a minority religious sect, fled the northern towns of Sinjar and Zumar, said Jawhar Ali Begg, a spokesman for the community.

“Thousands of Yazidi people have been killed,” he said. The militant group gave the Yazidis, who follow an ancient religion with links to Zoroastrianism, an ultimatum to convert to Islam, pay a tax or face death, Begg added.

Iraq is facing its worst crisis since the 2006 civil war when the Islamic State group, an al-Qaida breakaway faction with a strong presence in Syria, captured large swaths of land in the country’s west and north in a lightning offensive earlier this year.

The United Nations said last month that more than 500,000 people have been displaced by the violence since June, bringing the total this year to 1.4 million, including more than 230,000 Syrian refugees. The group drove ethnic and religious minorities out of Iraq’s second-largest city, Mosul, and attacked mosques and shrines, claiming they contradicted strict Islamic teachings.

Kurdish forces, known as the peshmerga, have been battling with the militants for control of several towns stretching between the province of Nineveh and the Kurdish Iraqi province of Dahuk. At least 25 Kurdish fighters were killed in clashes with the militants on Sunday, and another 120 were wounded, according to Muhssin Mohamed, a Dahuk-based doctor.

A statement Monday by the Islamic State said it had captured dozens of Kurdish prisoners during the clashes and seized “large number” of weapons.

The authenticity of the statement could not be verified, but it was posted on a website used by the group.