BAGHDAD — Sunni militants overran one of the last government-held crossings on the Syrian border on Friday after a fierce battle that left at least 34 Iraqi soldiers dead.

The fighting occurred as some clerics during Friday Prayer signaled that they wanted the Parliament to hasten the formation of a new government and reach across sectarian and ethnic divides.

Police and government officials reached in Qaim, the western border city of about 250,000 near the crossing, described a desperate, bloody struggle in which Iraqi Army troops were overwhelmed by “hundreds” of fighters from the Islamic State in Iraq and Syria. Fighters coming from Syria have been able to cross the desert freely for some time, but control of border crossings allows easier transport of fighters — including suicide bombers — and supplies, vehicles and heavy equipment.

“We would have stood and kept on fighting ISIS, but the government didn’t send us backup, and we were few in number and they had more fighters,” said Qaim’s mayor, Farhan al Qubaisi, who described a scene of heroic but ultimately futile resistance as the Iraqi soldiers were overrun. Still, a small part of the city and border crossing remained under government control late Friday, according to local officials and a Western military expert.