Islamist militants launched a rare attack inside Kurdish-held territory in northern Iraq on Tuesday, briefly taking over a local government compound near several producing oil fields.

The Kurds have largely managed to insulate their autonomous region from violent instability further south whilst holding a long front line against Islamic State militants who control a large part of Iraq.

Security sources said a suicide bomber had blown himself up at a checkpoint, clearing the way for three other militants to enter the compound in the town of Dibis 50 km (30 miles) south of the regional capital Erbil.

The three insurgents then occupied the mayor of Dibis's office, throwing grenades and firing at Kurdish security forces surrounding the compound, security sources said.

Kurdish forces regained control after one of the militants was shot dead and the other two blew themselves up, security sources said. At least four members of the Kurdish security forces were also killed.

Police Chief Serhat Qader said the attack was probably the work of a sleeper cell in Dibis, which has a mixed Arab and Kurdish population. A curfew was imposed on the town afterward.

Dibis, which is part of Kirkuk province, has been controlled by Kurdish forces since the Iraqi army's northern divisions collapsed in June 2014 as Islamic State overran around a third of the country, including the city of Mosul.

The United States intervened after the militants attacked and overcame the peshmerga, threatening to capture Irbil and wipe out Iraq's Yazidi minority.

Since then, the peshmerga have driven back the militants in the north, effectively expanding their region to include disputed territories to which both Kurds and Arabs lay claim.