The officials said today's attack, which killed 17 soldiers and six Sunni militia fighters, took place in the rural district of Jaramshah, north of Anbar's provincial capital, Ramadi.
The officials spoke on condition of anonymity because they were not authorised to speak to the media.
They said the IS fighters used suicide bombings and mortar shells and that chief of army operations in Anbar, Maj-Gen Qassim al-Dulaimi, was lightly wounded.