BAGHDAD (AP) -- Islamic State militants likely killed up to 500 Iraqi civilians and soldiers and forced 8,000 people to flee from their homes as they captured the Iraqi city of Ramadi, a provincial official said Monday, while the extremists went door-to-door looking for policemen and pro-government tribesmen.

Iraq's government and Iranian-backed Shiite militias vowed to mount a counter-offensive and reclaim Ramadi, the capital of the overwhelmingly Sunni Anbar province. Iran's Defense Minister Gen. Hossein Dehghan flew to Baghdad on a surprise visit for urgent talks with Iraqi leaders.

28 PHOTOS 8,000 flee Ramadi after ISIS takeover - Iraqi forces Anbar See Gallery ISIS killed hundreds as it took Iraq's Ramadi An Iraqi government forces member sits in the back of a vehicle in the Jurf al-Sakher area, some 50 kilometres south of Baghdad, to patrol the area from further Islamic State (IS) group advancement, on May 24, 2015. Iraqi forces retook territory from IS group east of Ramadi on May 23, 2015, in their first counterattack since the jihadists' capture of the Anbar provincial capital a week earlier. (Photo credit Haidar Hamdani, AFP/Getty Images) Iraqi government forces keep position in the Jurf al-Sakher area, some 50 kilometres south of Baghdad, to protect the area from further Islamic State (IS) group advancement, on May 24, 2015. Iraqi forces retook territory from IS group east of Ramadi on May 23, 2015, in their first counterattack since the jihadists' capture of the Anbar provincial capital a week earlier. (Photo credit Haidar Hamdani, AFP/Getty Images) Iraqi government forces pose for a picture at a checkpoint in the Jurf al-Sakher area, some 50 kilometres south of Baghdad, to protect the area from further Islamic State (IS) group advancement, on May 24, 2015. Iraqi forces retook territory from IS group east of Ramadi on May 23, 2015, in their first counterattack since the jihadists' capture of the Anbar provincial capital a week earlier. (Photo credit Haidar Hamdani, AFP/Getty Images) An Iraqi government forces member keeps position in the Jurf al-Sakher area, some 50 kilometres south of Baghdad, to protect the area from further Islamic State (IS) group advancement, on May 24, 2015. Iraqi forces retook territory from IS group east of Ramadi on May 23, 2015, in their first counterattack since the jihadists' capture of the Anbar provincial capital a week earlier. (Photo credit Haidar Hamdani, AFP/Getty Images) Iraqi government forces guard the Jurf al-Sakher area, some 50 kilometres south of Baghdad, to protect the area from further Islamic State (IS) group advancement, on May 24, 2015. Iraqi forces retook territory from IS group east of Ramadi on May 23, 2015, in their first counterattack since the jihadists' capture of the Anbar provincial capital a week earlier. (Photo credit Haidar Hamdani, AFP/Getty Images) Iraqi government forces keep position in the Jurf al-Sakher area, some 50 kilometres south of Baghdad, to protect the area from further Islamic State (IS) group advancement, on May 24, 2015. Iraqi forces retook territory from IS group east of Ramadi on May 23, 2015, in their first counterattack since the jihadists' capture of the Anbar provincial capital a week earlier. (Photo credit Haidar Hamdani, AFP/Getty Images) Iraqi government forces walk next to a trench in the Jurf al-Sakher area, some 50 kilometres south of Baghdad, to protect the area from further Islamic State (IS) group advancement, on May 24, 2015. Iraqi forces retook territory from IS group east of Ramadi on May 23, 2015, in their first counterattack since the jihadists' capture of the Anbar provincial capital a week earlier. (Photo credit Haidar Hamdani, AFP/Getty Images) Displaced Sunni Iraqis, who fled the violence in the Iraqi city of Ramadi, arrive at the outskirts of Baghdad, on April 19, 2015. More than 90,000 people have fled fighting between pro-government forces and the Islamic State jihadist group in the Ramadi area of Iraq's Anbar province, the United Nations said. (Photo credit Ahmad Al-Rubaye, AFP/Getty Images) Iraqi families, who fled the city of Ramadi after it was seized by Islamic State (IS) group militants, talk to journalists at a camp housing displaced families on May 18, 2015 in Bzeibez, on the southwestern frontier of Baghdad with Anbar province. Shiite militias converged on Ramadi in a bid to recapture it from jihadists who dealt the Iraqi government a stinging blow by overrunning the city in a deadly three-day blitz. (Photo credit Ahmad Al-Rubaye, AFP/Getty Images) Displaced Sunni Iraqis, who fled the violence in the Iraqi city of Ramadi, arrive at the outskirts of Baghdad, on April 19, 2015. More than 90,000 people have fled fighting between pro-government forces and the Islamic State jihadist group in the Ramadi area of Iraq's Anbar province, the United Nations said. (Photo credit Ahmad Al-Rubaye, AFP/Getty Images) An Iraqi boy, whose family fled the city of Ramadi after it was seized by Islamic State (IS) group militants, poses inside a tent at a camp housing displaced families on May 18, 2015 in Bzeibez, on the southwestern frontier of Baghdad with Anbar province. Shiite militias converged on Ramadi in a bid to recapture it from jihadists who dealt the Iraqi government a stinging blow by overrunning the city in a deadly three-day blitz. (Photo credit Ahmad Al-Rubaye, AFP/Getty Images) Thousands of Iraqis fleeing the Iraqi city of Ramadi seized by Daesh militants, cross bridge over Euphrates River to arrive in Baghdad, Iraq on April 17, 2015. Thousands of Iraqis have started to migrate from Ramadi city, where the U.S.-led coalition has intensified its airstrikes against Daesh positions, to Baghdad, said a security official. (Photo by Ali Mohammed/Anadolu Agency/Getty Images) Iraqi security forces stand guard as residents from the city of Ramadi, who fled their homes on May 16, 2015 as Islamic State (IS) group militants tightened their siege on the last government positions in the capital of Anbar province, a day after they seized the city's government headquarters, wait to cross Bzeibez bridge, on the southwestern frontier of Baghdad with Anbar province, after IS group jihadists took control of all the other routes connecting the province with the Iraqi capital. Taking control of Ramadi would constitute the group's most important victory this year in Iraq, and would give the jihadists control of the capitals of two of its largest provinces. (Photo credit Sabah Arar, AFP/Getty Images) Residents from the city of Ramadi, who fled their homes on May 16, 2015 as Islamic State (IS) group militants tightened their siege on the last government positions in the capital of Anbar province, a day after they seized the city's government headquarters, walk towards Bzeibez bridge, on the southwestern frontier of Baghdad with Anbar province, after IS group jihadists took control of all the other routes connecting the province with the Iraqi capital. Taking control of Ramadi would constitute the group's most important victory this year in Iraq, and would give the jihadists control of the capitals of two of its largest provinces. (Photo credit Sabah Arar, AFP/Getty Images) Thousands of Iraqis, fled the Iraqi city of Ramadi seized by Daesh militants, cross bridge over Euphrates River to arrive in Baghdad, Iraq on April 19, 2015. Thousands of Iraqis have started to migrate from Ramadi city, where the U.S.-led coalition has intensified its airstrikes against Daesh positions, to Baghdad, said a security official. (Photo by Visam Avci/Anadolu Agency/Getty Images) Iraqi children, fled the Iraqi city of Ramadi seized by Daesh militants, are carried by trailer after they arrive in Baghdad, Iraq on April 19, 2015. Thousands of Iraqis have started to migrate from Ramadi city, where the U.S.-led coalition has intensified its airstrikes against Daesh positions, to Baghdad, said a security official. (Photo by Visam Avci/Anadolu Agency/Getty Images) Iraqi children, fled the Iraqi city of Ramadi seized by Daesh militants, are carried by trailer as an Iraqi army soldier passes water them after they arrive in Baghdad, Iraq on April 19, 2015. Thousands of Iraqis have started to migrate from Ramadi city, where the U.S.-led coalition has intensified its airstrikes against Daesh positions, to Baghdad, said a security official. (Photo by Visam Avci/Anadolu Agency/Getty Images) An Iraqi kid cries as he and thousands of Iraqis fleeing the Iraqi city of Ramadi seized by Daesh militants, arrive in Baghdad, Iraq on April 17, 2015. Thousands of Iraqis have started to migrate from Ramadi city, where the U.S.-led coalition has intensified its airstrikes against Daesh positions, to Baghdad, said a security official. (Photo by Ali Mohammed/Anadolu Agency/Getty Images) An Iraqi woman fleeing the Iraqi city of Ramadi seized by Daesh militants, reacts as she arrives in Baghdad, Iraq on April 17, 2015. Thousands of Iraqis have started to migrate from Ramadi city, where the U.S.-led coalition has intensified its airstrikes against Daesh positions, to Baghdad, said a security official. (Photo by Ali Mohammed/Anadolu Agency/Getty Images) BAGHDAD, IRAQ - APRIL 19: Iraqis, fled the Iraqi city of Ramadi seized by Daesh militants, carry their belongings with a trailer after they arrive in Baghdad, Iraq on April 19, 2015. Thousands of Iraqis have started to migrate from Ramadi city, where the U.S.-led coalition has intensified its airstrikes against Daesh positions, to Baghdad, said a security official. (Photo by Visam Avci/Anadolu Agency/Getty Images) Thousands of Iraqis, fled the Iraqi city of Ramadi seized by Daesh militants, cross bridge over Euphrates River to arrive in Baghdad, Iraq on April 19, 2015. Thousands of Iraqis have started to migrate from Ramadi city, where the U.S.-led coalition has intensified its airstrikes against Daesh positions, to Baghdad, said a security official. (Photo by Visam Avci/Anadolu Agency/Getty Images) BAGHDAD, IRAQ - APRIL 17: Iraqi Army members take security measures as thousands of Iraqis fleeing the Iraqi city of Ramadi seized by Daesh militants, arrive in Baghdad, Iraq on April 17, 2015. Thousands of Iraqis have started to migrate from Ramadi city, where the U.S.-led coalition has intensified its airstrikes against Daesh positions, to Baghdad, said a security official. (Photo by Ali Mohammed/Anadolu Agency/Getty Images) Thousands of Iraqis fleeing the Iraqi city of Ramadi seized by Daesh militants, arrive in Baghdad, Iraq on April 17, 2015. Thousands of Iraqis have started to migrate from Ramadi city, where the U.S.-led coalition has intensified its airstrikes against Daesh positions, to Baghdad, said a security official. (Photo by Ali Mohammed/Anadolu Agency/Getty Images) An Iraqi woman fleeing the Iraqi city of Ramadi seized by Daesh militants, reacts as she arrives in Baghdad, Iraq on April 17, 2015. Thousands of Iraqis have started to migrate from Ramadi city, where the U.S.-led coalition has intensified its airstrikes against Daesh positions, to Baghdad, said a security official. (Photo by Ali Mohammed/Anadolu Agency/Getty Images) Residents from the city of Ramadi, who fled their homes on May 16, 2015 as Islamic State (IS) group militants tightened their siege on the last government positions in the capital of Anbar province, a day after they seized the city's government headquarters, walk towards Bzeibez bridge on the southwestern frontier of Baghdad with Anbar province, after IS group jihadists took control of all the other routes connecting the province with the Iraqi capital. Taking control of Ramadi would constitute the group's most important victory this year in Iraq, and would give the jihadists control of the capitals of two of its largest provinces.(Photo credit Sabah Arar, AFP/Getty Images) A member of the Iraqi interior ministry's anti-terrorism forces flashes the V-sign as he stands guard on a vehicle outside the Habaniyah military base, near Anbar province's capital Ramadi, on May 8, 2015. More than 1,000 Sunni fighters from Anbar joined Iraq's Popular Mobilisation force on May 8, 2015 as part of government efforts to make the fight against the Islamic State (IS) group a cross-sectarian drive. (Photo credit Ahmad Al-Rubaye, AFP/Getty Images) Volunteer Shiite fighters who supports the Iraqi government forces in the combat against the Islamic State (IS) group, hold a black Islamist flag allegedly belonging to IS militants in the village of Fadhiliyah, which pro-government forces retook from IS control the previous month, on the road leading to Fallujah, in Iraq's flashpoint Anbar province, southwest of Baghdad, on February 24, 2015. The government forces lost control of parts of Anbar's provincial capital Ramadi and all of Fallujah at the beginning of 2015 to anti-government fighters. (Photo credit Ahmad Al-Rubaye, AFP/Getty Images) An Islamic State car bomb explodes at the gate of a government building near the provincial governor's compound in Ramadi, Iraq, on Saturday, May 16, 2015, during heavy fighting that saw most of the city fall to the militants. (Stringer/McClatchy DC/TNS via Getty Images) Up Next See Gallery Discover More Like This HIDE CAPTION SHOW CAPTION of SEE ALL BACK TO SLIDE

The fall of Ramadi was a stunning defeat for Iraq's security forces and military, which fled as the Islamic State extremists overwhelmed the last hold-out positions of pro-government forces, despite the support of U.S.-led airstrikes targeting the extremists. Online video showed Humvees, trucks and other equipment speeding out of Ramadi, with soldiers desperate to reach safety gripping onto their sides.

Since Friday, when the battle for the city entered its final stages, "we estimate that 500 people have been killed, both civilians and military," said a spokesman for the Anbar provincial government, Muhannad Haimour.

The figures could not be independently confirmed, but Islamic State militants have in the past killed hundreds of civilians and soldiers in the aftermath of their major victories.

Some 8,000 people fled the city, Haimour said. It was not immediately clear how many people remain in Ramadi - once a city of 850,000 that has been draining population for months amid fighting with the extremists besieging it. An enormous exodus took place in April, when the U.N. estimates some 114,000 residents streamed out of Ramadi and surrounding villages.

Bodies, some charred, were strewn in the streets or tossed into the Euphrates river, said Naeem al-Gauoud, a leader from the Sunni tribes that fought against IS in Ramadi.

Ramadi's streets were deserted Monday, with only few people venturing out of their homes to look for food, according to two residents reached by telephone.

The militants, meanwhile, were storming the homes of policemen and pro-government tribesmen, particularly those from the large Al Bu Alwan tribe, of whom they detained about 30, the residents said. The militants went door-to-door with lists of alleged pro-government collaborators. Homes and stores owned by a pro-government Sunni militia known as the Sahwa were looted or torched.

The residents spoke to The Associated Press on condition of anonymity because they feared reprisals by the militants.

Sunday's defeat in Ramadi, 115 kilometers (70 miles) west of Baghdad, recalled the collapse of Iraqi forces last summer in the face of a blitz by the extremist group, when it took the northern city of Mosul and swept over much of the north and west of the country. Later, IS declared a caliphate in areas under its control in Iraq and neighboring Syria.

Backed by airstrikes from a U.S.-led coalition since August, Iraqi forces and allied militias have recaptured some of the areas seized by the Islamic State over the past year. But the new defeat in Anbar calls into question the Obama administration's hopes of relying solely on air power to support Iraqi forces in the battle against IS as well as whether these forces have sufficiently recovered from last year's stunning defeats.

U.S. Secretary of State John Kerry said he remained confident about the fight against the Islamic State group, despite the setbacks like the loss of Ramadi. Kerry, traveling through South Korea, said that he's long said the fight against the militant group would be a long one, and that it would be tough in Anbar province, where Iraqi security forces are not built up.

The militants are now believed to control of more than 60 percent of Anbar, which stretches from the western edge of Baghdad all the way to Syria and Jordan. The mostly desert province, where the population is almost entirely from Iraq's Sunni minority, was a heartland of the Sunni insurgency against U.S. troops following the 2003 U.S.-led invasion that toppled dictator Saddam Hussein.

Until now, the defense of Anbar had been in the hands of the military and Sunni tribesmen, whom the Shiite-led government has vowed to arm and support - but has only done slowly and partially.

But the fall of Ramadi now is prompting the entry of Shiite militias into the fray, raising the danger of frictions with the Sunni populace.

Shiite Prime Minister Haider al-Abadi ordered Shiite militias to prepare to go into Anbar, ignoring U.S. concerns their presence could spark sectarian bloodshed. By late Sunday, a large number of Shiite militiamen had arrived at a military base near Ramadi, apparently to participate in a possible counter-offensive, said the head of the Anbar provincial council, Sabah Karhout.

Youssef al-Kilabi, a spokesman for the Shiite militias fighting alongside government forces, told the AP on Monday that the Iranian-backed paramilitary forces have drawn up plans for a Ramadi counter-offensive in cooperation with government forces.

We will "eliminate this barbaric enemy," al-Kilabi vowed. He did not elaborate on the plans or the timing of a counter-offensive.

Shiite militias, many of them backed by Iran, have been key to victories against the Islamic State group on other fronts north of Baghdad in recent months. But they have also been widely criticized over charges of extrajudicial killings of Sunnis, as well as of looting and torching of Sunni property. Militia leaders deny these charges.

In the face of IS, some Sunnis appear ready to accept even the Shiite militiamen's help. Al-Gauoud, the Sunni tribal leader, said, "We welcome any group, including Shiite militias, to come and help us in liberating the city from the militants."

Abu Mohammed, a retired government employee from Ramadi, welcomed the participation of Shiite militias in liberating Ramadi. But Abu Ammar, another Anbar native who owns a grocery store in Ramadi, said he saw no difference between IS' brutal practices and those by Shiite militiamen.

"If the Shiite militias enter Ramadi, they will do the same things being done by Daesh," he said, using the Arabic acronym for the Islamic State. "In both cases, we will be either killed or displaced. For us, the militias and IS militants are two faces of the same coin."

The final IS push to take Ramadi began early Sunday with four nearly simultaneous bombings that targeted police officers defending the Malaab district in southern Ramadi, a pocket of the city still under Iraqi government control, killing at least 10 policemen and wounding 15, officials said. The militants then hit the provincial military headquarters with three suicide bombers, killing five soldiers.

Troops fled the headquarters, leaving behind some 30 vehicles and weapons including artillery assault rifles, and some two dozen police officers went missing during the fighting, according to one police officer stationed at the headquarters.

More from AOL.com:

Nearly 200 arrested after deadly biker fight

ISIS massacres at least 500 after seizing Iraqi city

Obama bans some police equipment in surprise move