BAGHDAD -- Islamic militants overran parts of Iraq's second-largest city of Mosul on Tuesday, driving security forces from their posts and seizing the provincial government headquarters, security bases and other key buildings. Gunmen cruised through neighborhoods, waving black banners while residents fled.

Prime Minister Nouri al-Maliki pressed parliament to declare a state of emergency.

The fight for Mosul was a heavy defeat in Baghdad's battle against a widening insurgency by a breakaway al Qaeda group, the Islamic State of Iraq and the Levant, which has been trying - with some success - to seize territory both in Iraq and neighboring Syria.

Earlier this year, the group captured another Iraqi city, Fallujah, in the west of the country, and government forces have been unable to take it back after months of fighting. The far larger Mosul is an even more strategic prize. The city and surrounding Ninevah province are a major export route for Iraqi oil and a gateway to Syria.

Get Breaking News Delivered to Your Inbox

Regaining Mosul poses a daunting challenge for al-Maliki. The city 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 Qaeda and U.S. and Iraqi forces carried out repeated offensives there, regaining a semblance of control but never routing the insurgents entirely.

Iraqi families fleeing violence in the northern Nineveh province gather at a Kurdish checkpoint in Aski kalak, 25 miles west of Arbil, in the autonomous Kurdistan region, on June 10, 2014. Suspected jihadists seized Iraq's entire northern province of Nineveh and its capital Mosul, the country's second-largest city, in a major blow to authorities, who appear incapable of stopping militant advances. SAFIN HAMED/AFP/Getty Images

Islamic militants and Iraqi troops have been fighting for days in Mosul. But Monday night and into early Tuesday, the government forces in the city appeared to collapse.

Insurgents overran the Ninevah provincial government building in the city - a key symbol of state control - in the evening, and security forces fled many of their posts. The fighters stormed police stations, bases and prisons, capturing weapons and freeing prisoners.

On Tuesday, Mosul residents said the militants appeared to be in control of several parts of the city, raising the black banners that are the emblem of the Islamic State. The residents spoke to The Associated Press by telephone on condition of anonymity, fearing for their safety.

The fighters also seized helicopters at Mosul airport and seized heavy equipment and weapons depots, parliament speaker Osama al-Nujaifi - a Sunni from Mosul - said in a televised address. South of Mosul, several villages and a military air base around the town of Shurqat, in Salahuddin province, also fell to militants, al-Nujaifi said.

"What happened is a disaster by any standard," he said. "The presence of these terrorist groups in this vast province ... threatens not just the security and the unity of Iraq, but the whole Middle East."

Al-Nujaifi said the terrorists are now setting their sights on Salahuddin, a province just north of Baghdad.

Al-Nujaifi blamed the fall of Mosul on "negligence" on the part of army forces and their withdrawal from the city.

Al-Nujaifi said he spoke to U.S. Ambassador Robert Beecroft, requesting U.S. support to repel the terrorists' attack by virtue of the Joint Cooperation agreement between the two countries. Ambassador Faily promised to promptly convey our request to the U.S. administration, al-Nujaifi said.

In a nationally televised press conference Tuesday, al-Maliki asked parliament to declare a state of emergency, acknowledging that militants had taken control of "vital areas in Mosul." He said the public and government must unite "to confront this vicious attack, which will spare no Iraqi."

State TV said parliament would convene Thursday. Under the constitution, parliament can declare a 30-day state of emergency on a two-thirds vote by its members, granting the prime minister the necessary powers to run the country. Legal experts said that could include powers to impose curfews, restrict public movements and censor the media.

"What happened is a disaster by any standard," al-Nujaifi - a Sunni from Mosul - said in a televised address. "The presence of these terrorist groups in this vast province ... threatens not just the security and the unity of Iraq, but the whole Middle East," he said.

He said militants had seized helicopters at Mosul airport and captured weapons depots, and captured several villages and a military airbase further south in Salahuddin province, he said.

Residents began fleeing Mosul - though the size of the flight was not yet clear. A government employee who lives about a mile from the provincial government building, 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, speaking on condition she be identified by a nickname for fear of her safety. "We are afraid ... There is no police or army in Mosul."

The assault in Mosul is also a sign of Iraq's reversals since American forces left the country in late 2011. Militants ramped their insurgency back up over the past two years. The Islamic State has presented itself as the Sunni community's champion against al-Maliki's Shiite-led government as the group fights on both sides of the border in what Iraqi officials have said is an attempt to carve out an enclave for itself in western Iraq and eastern Syria.

The group, which was once al Qaeda's branch in Iraq, was thrown out of the terrorist network after it expanded its operations in Syria against the orders of al Qaeda leader Ayman al-Zawahri. It is considered one of the most ruthless rebel forces fighting to topple President Bashar Assad in Syria, where it has in seized a major city in the east and other territory.

In Iraq, the group rose up earlier this year to take over Fallujah and parts of the nearby city of Ramadi, the capital of Anbar province. It has also been carrying out a campaign of bombings and other violence in Baghdad and other parts of the country.

In the Mosul fighting, insurgents armed with machineguns and rocket-propelled grenade launchers stormed the provincial headquarters building late Monday, overpowering guards in a short firefight, according to Ali Mahmoud, the media official for Ninevah province.

He confirmed accounts by Mosul residents that many of the police and army forces that had been stationed in the city had disappeared by Tuesday.

Provincial governor Atheel al-Nujaifi, the parliament speaker's brother, was in a nearby guest house. He managed to escape the area and left the city, though he continues to monitor the situation, Mahmoud said.

On Monday, the governor had urged residents to fend off the attackers.

"I call upon the men of Mosul to stand firm in their areas and to defend them against the strangers and to form public committees in their districts to help their people and to protect their areas," he said in a transcript of a speech posted online.