BAGHDAD — Assailants waving the battle flag of al-Qaida gunned down 25 policemen Monday in a brazen and well-orchestrated challenge to government control over a strategic town fraught with Iraq war symbolism.

The attack replicated tactics used by Sunni insurgents during the war and appeared aimed at reasserting al-Qaida’s grip now that the Iraqis can no longer rely on American help.

The attackers drove through the town of Haditha claiming to be government officials and methodically executed guards and commanders. After half an hour they escaped into the desert, leaving a terrified populace demanding protection. Local authorities imposed a curfew and deployed troops.

Mohammed Owda al-Kubaisi, a relative of one of the slain policemen, spoke of his four children, “now orphans because their father was assassinated by the cold blood of insurgency while our government keeps watching and denouncing.”

Iraqi officials described Monday’s attack as a systematic plot to kill policemen. The attackers came at 2 a.m. in cars painted as Iraqi Interior Ministry vehicles and brandished false arrest warrants for city police officials. At the first checkpoint they confiscated cell phones and shot nine guards, said Mohammed Fathi, spokesman for the governor of Anbar province.

The convoy then stopped at the homes of two Haditha police commanders, including the colonel who served as the city’s SWAT team leader. They were killed less than a quarter of a mile away, Fathi said.

Six policemen were killed in a gunbattle that broke out at a checkpoint near the main market, and another eight were killed as security forces chased the gang through the city, Fathi said.

Most of the gang escaped north, but one of the insurgents’ cars was shot up and found to contain an al-Qaida flag and al-Qaida propaganda. Fathi said at least one of the insurgents was killed. Local police said three were killed.

The attack exposed the vulnerability of the Iraqi public, which has only a reconstituted and relatively untested Iraqi security force for protection.

Attacks by al-Qaida affiliates in Iraq as well as Yemen show a resilience that has survived the weakening of the central leadership by U.S. drone attacks on its Pakistan bases and the deaths of Osama bin Laden and other key figures.

Al-Qaida in Iraq reached the height of its strength during the 2005-2007 insurgency against U.S. troops. The Iraqi wing of the terror network still launches deadly attacks every few weeks, seeking to undermine the government and local security forces.