By SAMEER N. YACOUB and ADAM SCHRECK, Associated Press

BAGHDAD (AP) — In a stunning assault that exposed Iraq's eroding central authority, al-Qaida-inspired militants overran much of Mosul on Tuesday, seizing government buildings, pushing out security forces and capturing military vehicles as thousands of residents fled the second-largest city.

The rampage by the black banner-waving insurgents was a heavy defeat for Prime Minister Nouri al-Maliki as he tries to hold onto power, and highlighted the growing strength of the Islamic State of Iraq and the Levant. The group has been advancing in both Iraq and neighboring Syria, capturing territory in a campaign to set up a militant enclave straddling the border.

There were no immediate estimates on how many people were killed in the assault, a stark reminder of the reversals in Iraq since U.S. forces left in late 2011.

Earlier this year, Islamic State fighters took control of Fallujah, and government forces have been unable to take it back.

Mosul is a much bigger, more strategic prize. The city and surrounding Ninevah province, which is on the doorstep of Iraq's relatively prosperous Kurdish region, are a major export route for Iraqi oil and a gateway to Syria.

"This isn't Fallujah. This isn't a place you can just cordon off and forget about," said Michael Knights, a regional security analyst at the Washington Institute for Near East Policy. "It's essential to Iraq."

Al-Maliki pressed parliament to declare a state of emergency that would grant him greater powers, saying the public and government must unite "to confront this vicious attack, which will spare no Iraqi." Legal experts said these powers could include imposing curfews, restricting public movements and censoring the media.

State TV said lawmakers would convene Thursday. Parliament speaker Osama al-Nujaifi, a Sunni from Mosul, called the rout "a disaster by any standard."

Regaining Mosul poses a daunting challenge for the Shiite prime minister. The city of about 1.4 milliion has a Sunni Muslim majority and many in the community are already deeply embittered against his Shiite-led government. During the nearly nine-year American presence in the country, Mosul was a major stronghold for al-Qaida. U.S. and Iraqi forces carried out repeated offensives there, regaining a semblance of control but never routing the insurgents entirely.

"It's going to be difficult to reconstitute the forces to clear and hold the city," Knights said. "There aren't a lot of spare forces around Iraq."

White House spokesman Josh Earnest deplored what he called the "despicable" acts of violence against civilians in Mosul. He said Washington is committed to its partnership with Baghdad but is urging the government to take steps to be more inclusive of all Iraqis.

U.N. Secretary-General Ban Ki-moon condemned the attacks across Iraq in recent days "that have killed and wounded scores of civilians." He urged all political leaders "to show national unity against the threats facing Iraq, which can only be addressed on the basis of the constitution and within the democratic political process," according to U.N. spokesman Stephane Dujarric.

Insurgents and Iraqi troops have been fighting for days in Mosul, but the security forces' hold appeared to collapse late Monday night and early Tuesday.

Gunmen overran the Ninevah provincial government building — a key symbol of state control — Monday evening, and the governor fled the city. The fighters stormed police stations, bases and prisons, capturing weapons and freeing inmates. Security forces melted away, abandoning many of their posts, and militants seized large caches of weapons.

They took control of the city's airport and captured helicopters, as well as an airbase 60 kilometers (40 miles) south of the city, the parliament speaker said.

Later Tuesday, Islamic State fighters took over the large town of Hawija, 125 kilometers (75 miles) south of Mosul, according to officials there.

On Tuesday, the militants appeared to hold much of the eastern half of Mosul, which is bisected by the Tigris River. Residents said fighters were raising the black banners that are the emblem of the Islamic State.

Video taken from a car driving through the streets of Mosul and posted online showed burning vehicles in the streets, black-masked gunmen in pickup trucks mounted with anti-aircraft guns, and residents walking with suitcases.

ISIL supporters posted photos on social media showing fighters next to Humvees and other U.S.-made military vehicles captured from Iraqi forces.

The video and photos appeared authentic and matched Associated Press reporting of the events.

A government employee who lives about a mile from the provincial headquarters, Umm Karam, said she left with her family Tuesday morning.

"The situation is chaotic inside the city and there is nobody to help us," she said "We are afraid. ... There is no police or army in Mosul." She spoke on condition she be identified only by her nickname for fear of her safety.

An estimated 500,000 people have fled Mosul, according to a U.N. spokesman in New York, citing the International Organization for Migration. The spokesman said aid organizations hope to reach those in need with food, water, sanitation and other essential supplies as soon as the volatile security situation permits.

The Islamic State has ramped up its insurgency over the past two years, presenting itself as the Sunni community's champion against al-Maliki's government

The group was once al-Qaida's branch in Iraq, but under its leader Abu Bakr al-Baghdadi it has escalated its ambitions, sending fighters into Syria to join the rebellion against President Bashar Assad. Its jihadists became notorious as some of the most ruthless fighters in the rebellion — and other rebels turned against it, accusing it of trying to hijack the movement. Al-Qaida's central command, angered over its intervention in Syria, threw the group out of the terrorist network.

But it has been making gains on both sides of the border. In Syria, it took control of an eastern provincial capital of Raqqa, and in the past month it has launched an offensive working its way toward the Iraqi border.

Islamic State fighters in eastern Syria crossed into Iraq to help their brethren in the Mosul area, activists on the Syrian side said. They tried to take the border crossing itself, but Kurdish fighters on either side fended them off. The militants were able to seize the nearest Iraqi town to the border, Rabeea, the activists said.

The group earlier this year took over Fallujah and parts of Sunni-dominated Anbar province, and has stepped up its long-running campaign of bombings and other violence in Baghdad and elsewhere.

The Mosul crisis comes as al-Maliki is working to assemble a coalition after elections in late April, relying even more on Shiite parties. Sunnis and Kurds have grown increasingly disillusioned with al-Maliki, accusing him of dominating power.

The autonomous Kurdish region in the north has its own armed forces — the peshmerga — and on Tuesday, the region's prime minister suggested his willingness to intervene beyond the formal borders of the self-ruled enclave. That could be politically explosive, since the Mosul region lies on Kurdistan's doorstep, has a significant Kurdish population, and the Kurds claim parts of the area.

Militant gains in territories the Kurds consider theirs could push them "to send in their own troops to protect communities they consider as part of their jurisdiction," said Jordan Perry, an analyst at risk analysis firm Maplecroft.

Kurdistan's prime minister, Nechirvan Barzani, sharply criticized Baghdad's handling of the Mosul crisis, saying the Kurds had tried unsuccessfully to work with Iraqi security forces to protect the city.

"Tragically, Baghdad adopted a position which has prevented the establishment of this cooperation," he said in a statement.

Barzani urged the Kurds to aid those displaced from Mosul and called on the U.N. refugee agency to help with the relief effort. He said the peshmerga are prepared to handle security in areas outside the regional government's jurisdiction — presumably referring to parts around Mosul inhabited by Kurds that are disputed with the central government.

Kurdish official Razgar Khoushnaw said about 10,000 Mosul residents took refuge Tuesday in the Kurdish province of Irbil, while security officials in neighboring Dahuk province said 5,000 displaced people were let in there.

Far larger numbers of people are believed to have fled Mosul for other communities in the Ninevah countryside.

___

Schreck reported from Dubai, United Arab Emirates. Diaa Hadid and Bassem Mroue in Beirut and Edith M. Lederer at the United Nations contributed to this report.

___

Follow Adam Schreck on Twitter at www.twitter.com/adamschreck