CAIRO — Libyan officials were cautious on Thursday about declaring complete victory over the Islamic State in the coastal city of Surt, saying unknown numbers of the militant organization’s extremists remained ensconced in three neighborhoods.

While the Islamic State’s headquarters in the heavily fortified Ouagadougou Center, as well as an adjacent hospital and other important buildings, were taken on Wednesday by pro-government militiamen backed by American airstrikes, the fight was clearly far from over.

“If we knew how many of them were left there, we would attack tomorrow,” said Mohammed al-Ghasari, the spokesman for pro-government militia forces. “So far we have been very professional and careful.”

The newly returned mayor of Surt, Mukhtar Khalifa, told The Associated Press that the militiamen, who were from the neighboring city of Misurata and aligned with the United Nations-backed government in Tripoli, controlled 70 percent of the city. The mayor, who had vacated Surt while the Islamic State controlled it, predicted the rest of the city would soon fall as well.