BAGHDAD — Black-clad Sunni militants of Al Qaeda destroyed the Falluja Police Headquarters and mayor’s office, planted their flag atop other government buildings and decreed the western Iraqi city to be their new independent state on Friday in an escalating threat to Prime Minister Nuri Kamal al-Maliki, whose forces were struggling to retake control late into the night.

The advances by the militants — members of the Islamic State of Iraq and Syria, or ISIS — came after days of fighting in Falluja, Ramadi and other areas of Anbar Province. The region is a center of Sunni extremism that has grown more intense in reaction to Mr. Maliki’s Shiite-dominated government in Baghdad and the neighboring civil war in Syria.

Assertions by Islamic State of Iraq and Syria fighters that they were in complete control of Falluja were disputed by government security forces and an alliance of tribal leaders who have joined them. By nightfall, the security forces and tribal militia members had recaptured a part of the main street and a municipal building.

Mohamed al-Isawi, the head of the Falluja police, said in a telephone interview that he was gathering men in an area north of Falluja, as a staging ground for what he hoped would be a decisive battle to retake full control of the city.