Iraqi military and police officials say 17 soldiers and six allied Sunni fighters have been killed in an attack by Islamic State militants in the turbulent Anbar province west of Baghdad.

They said Sunday's attack took place in the rural district of Jaramshah north of Anbar's provincial capital, Ramadi.

They said the IS fighters used suicide bombings and mortar shells in the attack. The chief of army operations in Anbar, Maj-Gen. Qassim al-Dulaimi, was lightly wounded in the attack, the officials said.

The officials spoke on condition of anonymity because they were not authorized to speak to the media.

News of Sunday's attack came two days after up to 50 soldiers were killed by the IS in two ambushes elsewhere in Anbar province, much of which is under IS control.