BAGHDAD—Gunmen executed a former Iraqi counterterrorism commander and roughly two dozen policemen in a brazen operation that further undermined a government push for insurgents to lay down their arms.

Officials in the capital and in Anbar province, where the raid took place Monday, blamed insurgents from the Islamic State of Iraq, an affiliate of al Qaeda in Iraq. There was no immediate claim of responsibility.

The...