Prime Minister Recep Tayyip Erdogan of Turkey was holding an emergency meeting with top security officials on Wednesday to discuss the crisis.

Refugees flee from Mosul and head to the self-ruled northern Kurdish region in Irbil. Ap

Sunni militants who overran the northern Iraqi city of Mosul as government forces crumbled in disarray extended their reach in a lightning advance on Wednesday, pressing south toward Baghdad. They occupied facilities in the strategic oil refining town of Baiji and seized the city of Tikrit with little resistance, security officials and residents said.

By late Wednesday there were unconfirmed reports that the Sunni militants, many aligned with the radical Islamic State of Iraq and Syria, were battling loyalist forces at the northern entrance to the city of Samarra, about 70 miles north of Baghdad. The city is known for a sacred Shiite shrine that was bombed in 2006, during the height of the American-led occupation, touching off sectarian mayhem between the Sunni minority and Shiite majority.

The remarkably fast advance of the Sunni militants, who now control strategically important swaths of northern and western Iraq, reflects the spillover of the Sunni insurgency in Syria and the inability of Iraq’s Shiite-led government to pacify the country in the more than two years since American forces departed after eight years of war and occupation.

Insurgents also raided the Turkish consulate in Mosul and seized the consul general and 47 other Turkish citizens, including special-forces soldiers and three children of diplomats, the Turkish prime minister’s office said. The development raised the possibility that Turkey, a NATO ally that borders both Syria and Iraq, would become directly entangled in the fast-moving crisis.

Prime Minister Recep Tayyip Erdogan of Turkey was holding an emergency meeting with top security officials on Wednesday to discuss the crisis, and the Turkish foreign minister cut short a trip to New York and was returning to Ankara, government statements said.

Citizens in Baiji, a city of 200,000 about 110 miles south of Mosul, awoke Wednesday to find that government checkpoints had been abandoned and that insurgents, arriving in a column of 60 vehicles, were taking control of parts of the city without firing a shot, the security officials said. Peter Bouckaert, the emergency services director for Human Rights Watch, said in a post on Twitter that the militants had seized the Baiji power station, which supplies electricity to Baghdad, Kirkuk and Salahuddin Province.

In Tikrit, famous as the hometown of Saddam Hussein, residents said the militants attacked in the afternoon from three directions: east, west and north. Residents said there were brief exchanges of gunfire, and then police officers and soldiers shed their uniforms, put on civilian clothing and fled through residential areas to avoid the militants.

The militants’ advance spread alarm in Baghdad, 110 miles south. Though the city seemed calm, residents said they were shocked by the news and feared that the Islamic State of Iraq and Syria would push on toward the capital.

Shiite militias and security forces loyal to the Shiite-led government of Prime Minister Maliki were on high alert, and residents in Baghdad began stockpiling food, fuel and small arms in fear of a rebel assault.