CLARK, Philippines — Philippine troops have captured a building where pro-Islamic State group militants made their final stand in southern Marawi city and found about 40 bodies of suspected gunmen inside, two security officials told The Associated Press on Monday.

The officials said the seizure of the building and the defeat of the militants would allow the military to declare later on Monday the end of the Marawi siege, which hundreds of black flag-waving gunmen launched exactly five months ago.

The two officials spoke to The AP on condition of anonymity because they were not authorized to make public the latest developments in Marawi, where government forces have begun a gradual withdrawal as the fighting considerably eased in recent days.

It’s possible that a few militants may still be hiding. It was not immediately clear how the dozens of suspected militants found in the two-story building near Lake Lanao died but it’s possible some committed suicide after they were cornered by troops, one of the officials said.

The siege sparked fears the Islamic State group may gain a foothold in Southeast Asia by influencing and providing funds to local militants as it suffers battle defeats in Syria and Iraq. The defeat of the IS-linked uprising and the killings of its leaders by Filipino troops, however, have provided a relief to the region, where terrorism remains a key security concern.

Southeast Asian defense ministers opened their annual meeting at the Clark freeport north of Manila on Monday, with counter-terrorism strategies high on the agenda. As the meetings opened, the head of the Brunei delegation expressed condolences for the loss of lives in Marawi but congratulated the Philippines for being able to liberate the city.

Army Col. Romeo Brawner has said troops were aiming to end the crisis before midnight Sunday. The remaining gunmen, who include some Indonesian and Malaysian fighters, have the option of surrendering, or they can either be captured or killed, Brawner said.

“Our government forces will try to do everything to finish the firefight today,” Brawner said in a news conference on Sunday in Marawi.

“It’s either they all get killed, because they’re determined to die inside, or we capture them or they surrender,” he said.

The fighting has left at least 1,131 people dead, including 919 militants and 165 soldiers and policemen. While the fighting raged at noon on Sunday, troops continued to us loudspeakers to ask the gunmen to surrender, Brawner said.

Military chief of staff Gen. Eduardo Ano said Sunday some of the remaining militants were “suicidal.”

Hundreds of militants, many waving Islamic State group-style black flags, launched the siege on May 23 in Marawi, a bastion of Islamic faith in the south of the largely Roman Catholic Philippines, by seizing the lakeside city’s central business district and outlying communities. They ransacked banks and shops, including gun stores, looted houses and smashed statues in a Roman Catholic cathedral, according to the military.

At least 1,780 of the hostages seized by the militants, including a Roman Catholic priest, were rescued, and a final group of 20 captives were freed overnight, Brawner said. That left the gunmen with none of the hostages they had used as human shields to slow the military advance for months.

The disastrous uprising, which has displaced hundreds of thousands of Marawi residents, erupted as the Philippines was hosting annual summit meetings of the Association of Southeast Asian Nations this year, along with the 10-nation bloc’s Asian and Western counterparts, including the United States and Australia. The two governments have deployed surveillance aircraft and drones to help Filipino troops rout the Marawi militants.

Last Monday, troops killed the final two surviving leaders of the siege, including Isnilon Hapilon, who is listed among the FBI’s most-wanted terror suspects in the world, and Omarkhayam Maute. Following their deaths, President Rodrigo Duterte traveled near the main scene of battle and declared Marawi had been essentially liberated from terrorist influence, although skirmishes with a few dozen gunmen continued.

DNA tests done in the United States requested by the Philippine military have confirmed the death of Hapilon, according to the U.S. Embassy in Manila. Washington has offered a bounty of up to $5 million for Hapilon, who had been blamed for kidnappings for ransom of American nationals and other terrorist attacks.

Among the foreign militants believed to be with the remaining gunmen in Marawi were Malaysian militant Amin Baco and an Indonesian known only as Qayyim. Both have plotted attacks and provided combat training to local militants for years but have eluded capture in the south.