The Iraqi city of Ramadi has been mostly freed from Islamic State (IS) control thanks to a joint US-Iraq military campaign, months after Iraqi forces fled the city in May.

Spokesman Brig. Gen. Yahya Rasul announced Monday his troops had been victorious in its “epic” engagement, and local television has shown the Iraqi flag replacing the IS logo in much of the city. Encouraged by the operation, Rasoul maintained confidence that Iraq will continue to retake cities controlled by Islamic State. “We will liberate all the other places like we liberated Jurf al Nasser and Tikrit and Baiji and other areas,” Rasoul said.

Iraq’s military had been fighting for almost a month to take control of the city. Brig Gen Majd al-Fatlawi told AFP Islamic State “planted more than 300 explosive devices on the roads and in the buildings of the government complex.”

But it is still too early to say Iraq has total control over the city, according to Gen Ismail al-Mahlawi, who told AP that IS jihadis still control pockets within the city. Other reports have also suggested that IS may have regrouped in the city’s north, and that its forces still have the capacity to conduct a counter-attack.

Ramadi, a city with almost half a million residents, was captured by IS in May following a months-long campaign of militant operations. Defense Secretary Ash Carter criticized Iraqi forces at the time, saying they showed no will to protect their own country.

The Pentagon told the BBC Monday the operation to take back Ramadi is a “proud moment for Iraq,” and that “the coalition will continue to support the government of Iraq as they move forward to make Ramadi safe for civilians to return.”

“The clearance of the government center is a significant accomplishment and is the result of many months of hard work by the Iraqi Army, the Counter Terrorism Service, the Iraqi Air Force, local and federal police and tribal fighters,” said Pentagon spokesman Col. Steve Warren on Monday.

Analysts believe some within Sunni-populated Ramadi may clash with their “liberators” in the Shiite-majority Iraqi military, creating the possibility that sectarian conflict will arise. Additionally, the Iran-backed Shiite militias, which accompanied the Iraqi military in its assault on Ramadi are notorious, have been accused of targeting innocent Sunni civilians.