Islamic State militants raised their black flag over the local government headquarters in the Iraqi city of Ramadi on Friday and claimed victory through mosque loudspeakers after overrunning most of the western provincial capital.
If Ramadi were to fall it would be the first major city seized by the insurgents in Iraq since security forces and paramilitary groups began pushing them back last year.
The insurgents attacked Ramadi overnight using six suicide car bombs to reach the city centre, where the Anbar provincial government compound is located, police sources said.
Fighting continued in one district of Ramadi, 100 km (60 miles) west of Baghdad, and government forces were still in control of a military command centre to the west of the city.
"The situation in Ramadi is dire, but the city has not fallen and the battle against criminal Daesh is still ongoing," Anbar governor Sohaib al-Rawi said on Twitter, using an Arabic name for Islamic State.
Ramadi has been fought over for months, but the insurgents renewed their offensive there in April, crushing government forces' efforts to retake Anbar, Iraq's largest province, and move north to the Islamic State stronghold of Mosul.
An army major whose regiment is positioned near the Anbar operations command described the situation as critical and said the militants had taken control of the only major supply route into the city, making it difficult to send reinforcements.
Most army and police units have retreated to the area around the operation command to protect it, he said, but some elite counter-terrorism forces were "fighting for their lives" in the Malaab district of central Ramadi, where they were surrounded.
"If the government does not send any reinforcements and the coalition air force does not rescue us, we will lose all of Ramadi by midnight," the major said.
"A massacre will take place and all of us will be slaughtered. We have been defending the city for months and we don't deserve to end like this. It's humiliating."
Prime Minister Haider al-Abadi met with military and security leaders as well as the heads of the air force and counter-terrorism on Friday and pledged to intensify efforts to "expel the terrorist gangs from Ramadi".
Ramadi is one of the few towns and cities to have remained under government control in the vast desert province, which borders Saudi Arabia, Syria and Jordan.
More than 130,000 people have fled Anbar since the militants renewed their offensive on Ramadi last month, according to the International Organisation for Migration. People who had stayed were trying to leave on Friday, but found themselves trapped.
Fifty-seven-year-old shop owner Abu Raad told Reuters he had seen uniforms and weapons discarded by the security forces in the streets. "We are currently being patient and hope that God will save us from this ordeal. We have no where else to go."
In an audio recording issued by Islamic State on Thursday purporting to come from its leader Abu Bakr al-Baghdadi, the self-proclaimed caliph urged displaced residents of Anbar to return to their homes in the Sunni heartland: "For you are our people. We defend you, your honour, and your wealth."
Baghdadi also hailed the Islamic State fighters who had "snatched Anbar from the eyes of the apostates and the throats of the Rafeda, in spite of America and its allies," using a derogatory term for Shi'ite Muslims and referring to US-led coalition air strikes.
Friday's offensive began with the militants using an armoured bulldozer to remove blast walls blocking the road to the police department next to the governorate building and blew the vehicle up when it reached there.
A Humvee packed with explosives targeted the education department in the same compound and a third car bomb was detonated at the western entrance to the governorate building itself. Three more car bombs blew up near the Anbar Operations Command.