UN Secretary-General Antonio Guterres has urged Kurds in Iraq to scrap plans to hold a referendum on independence later this month, arguing it would detract from the fight against the Islamic State of Iraq and the Levant (ISIL, also known as ISIS) group.

Guterres said in a statement on Sunday that any dispute between the Iraqi government and the Kurdistan Regional Government should be resolved through dialogue and "constructive compromise".

Iraq's semi-autonomous Kurdish region of northern Iraq plans to hold the referendum on support for independence on September 25 in three governorates that make up the region, and in disputed areas controlled by Kurdish forces, but which are claimed by Baghdad.

Guterres said, "any unilateral decision to hold a referendum at this time would detract from the need to defeat ISIL".

It would also undermine reconstruction efforts and the return of refugees, he added.

Iraqi forces have slowly retaken territory from ISIL over the past three years. In July, they retook Mosul and effectively shattered ISIL's self-declared territorial caliphate.

Despite the losses, ISIL continues to carry out attacks in Iraq. On Thursday, an attack claimed by ISIL at a checkpoint and restaurant in southern Iraq left more than 80 killed and 93 wounded.

Since 2014, more than three million people have been displaced, and thousands of civilians and security forces have been killed.

The leaders of Iraq's Kurdish region have said they hope the referendum will push Baghdad to come to the negotiating table and create a path for independence.

On Friday, the United States said the referendum should be called off, a stance also pushed by neighbouring Turkey, which fears it could create another source of conflict in the region.

Iran issues warning

Iran warned on Sunday that independence for Iraqi Kurds would mean an end to all border and security arrangements with the regional government.

Al Jazeera's Hoda Abdel-Hamid, reporting from Erbil, said Iran sees the referendum as a "threat to its national security".

Ali Shmkhani, Iran's national security secretary, said that Iran has regarded the Kurds in northern Iraq as brothers and allies and supported them during difficult times, but the referendum is neither legal nor conducive to the security of Iraq or the region, according to the ISNA news agency.

READ MORE: Iraqi parliament rejects Kurdish push for independence

The security official added that a vote in favour of independence would also compel Iran to introduce strict border controls.

Though there are no major ethnic conflicts in Iran involving the country's seven million Kurds, Tehran fears that a neighbouring Kurdish state could contribute to secessionist ideas.

Military intervention

The UN's Guterres urged Iraqi leaders to "approach this matter with patience and restraint" and offered UN help to address the issue.

On Saturday, Iraqi Prime Minister Haider al-Abadi said Iraq is prepared to intervene militarily if the Kurdish region's planned independence referendum results in violence.

If the Iraqi population is "threatened by the use of force outside the law, then we will intervene militarily," he said in an interview with The Associated Press.

UN envoy to Iraq, Jan Kubis, told Iraqi Kurdish leader Massud Barzani last week that the UN was ready to broker negotiations to address "all the problems and outstanding issues" between the Kurds and Baghdad, according to a document obtained by AFP news agency.

The negotiations would aim to reach a deal within two or three years on the "principles and arrangements" for future relations between Baghdad and the Kurdish region, the document said.

In return, Barzani's administration would agree to postpone the referendum at least until the end of negotiations.

Iraq's Kurds have long held a dream of statehood. Oppressed under former President Saddam Hussein - whose military in the 1980s killed at least 50,000 Kurds, many with chemical weapons - Iraq's Kurds established a regional government in 1992 after the US enforced a no-fly zone across the north following the Gulf War.

After the 2003 US-led invasion overthrew Hussein, the region secured constitutional recognition of its autonomy but remained part of the Iraqi state.