Dozens of Iraqi government forces and militia members have been killed in an attack on military barracks east of Fallujah by the Islamic State of Iraq and the Levant (ISIL).

Military sources said 50 members of the Iraqi security forces and allied Shia militias were killed on Saturday.

ISIL losses were reported too, with sources close to the group saying 12 of its fighters were killed by helicopter gunships.

On May 23, Haider al-Abadi, Iraq's prime minister, announced the start of the offensive to "liberate Fallujah" from ISIL.

For almost two years, Fallujah, which is just 50km west of the capital Baghdad, has endured a siege imposed on the city after it became the first to fall to ISIL in January 2014.

OPINION: What success would look like in Fallujah

Matthew Glanville, former adviser to the governor of Anbar province, believes the Iraqi forces were overly confident in their operation to recapture Fallujah.

"The lesson from the earlier offensive against Tikrit last year was that where ISIL had the opportunity to dig in, particularly among the civilian population, it was always going to take a very long time to get them out without civilian casualties," Glanville told Al Jazeera.

"While Fallujah itself has been isolated, the wider ISIL movement still has the capacity to fight back. The time the Iraqi government has spent putting together this offensive has given ISIL even more time to dig in."

An example of ISIL's defence strategies was revealed earlier this week, when the army discovered a network of tunnels near the southern edge of the city.

It is believed that up to 90,000 civilians are still inside Fallujah.

Although the Iraqi government said it had a particular strategy to establish safe corridors for civilians in the city centre to leave, Glanville said many are reluctant to go from fear of how they may be treated by the Shia forces.

The humanitarian crisis in Iraq has been dubbed one of the world's worst by the UN.

Since the beginning of the present conflict in 2014, more than 3.4 million people have been internally displaced and 2.6 million have fled Iraq.