Manila, Philippines (CNN) Two key ISIS-affiliated leaders engaged in a standoff with Philippines forces in the southern city of Marawi have been killed, the country's Defense Secretary Delfin Lorenzana said Monday.

The two leaders were named as Isnilon Hapilon, who was declared the terror group's emir for Southeast Asia, and Omar Maute, a leader of a local militant group that had pledged allegiance to ISIS.

The pair were killed, along with seven other militants, while attempting to exit a building at street level during a four-hour firefight, Gen. Eduardo Ano of the Philippines Armed Forces said at a news conference. Maute was shot in the head by a sniper.

Their bodies were positively identified by a former hostage, Ano said. They will be buried in accordance with Islamic rites in an undisclosed location.

"It will be just a matter of days before it can finally be declared that Marawi has been liberated from the clutches of terrorists," he said.

More than 800 militants and 162 government security forces have been killed in the nearly 150 days of fighting, and about 1,700 hostages have been rescued, including 20 on Monday, said Ano.

The deaths of both Hapilon and Maute will likely hasten the retreat of ISIS-affiliated militants from Marawi, according to Richard Heydarian, a security analyst and author of the new book "The Rise of Duterte: A Populist Revolt against Elite Democracy."

"The political and military leadership of the ISIS movement (in the Philippines) has essentially been neutralized," Heydarian told CNN.

There are still 22 hostages and eight foreign militants remaining, according to Ano.

Isnilon Hapilon in a photo issued by the FBI which was seeking his capture.

How the fighting started

The fighting began on May 23 when the military launched an operation targeting Hapilon on the island of Mindanao, where Marawi is located.

Hapilon is thought to have issued an emergency call for reinforcements from members of the Maute group, which was headed by Omar and his brother Abdullah.

Abdullah was rumored to have been killed in early September, but the military has yet to confirm his death. Omar's death had been reported multiple times in the past, though never confirmed.

"The Maute brothers were essentially the military brain and engine of the whole ISIS-affiliated movement in the Philippines," Heydarian said.

After Hapilon called for backup, militants poured into the city by the hundreds, setting fire to buildings, taking hostages and entering into running street-battles with government forces.

The violence forced over 350,000 residents to flee the city and the surrounding areas, and saw President Rodrigo Duterte declare martial law across the island shortly after.

The Philippines Congress granted Duterte's request in July to extend the emergency measure until the end of the year, despite questions over the move's constitutionality.

Who was Hapilon?

Hapilon, a skinny, baby-faced 51-year-old with a tufty goatee beard, had been dodging Philippines authorities for over a decade, since he emerged as a ruthless and deadly commander of the Abu Sayyaf militant group in the early 2000s.

Abu Sayyaf is a violent extremist group with a history of kidnappings-for-ransom and bombings that split from the separatist movement the Moro National Liberation Front in 1991. The group is fragmented and there is no unified command.

The group is thought to have several hundred members -- and maintains strong ties to other local militant groups, according to the Jakarta-based Institute for Policy Analysis of Conflict (IPAC). It operates in the semi-lawless tri-border area between the Philippines, Malaysia and Indonesia, which has long been a haven for smugglers, pirates and other criminals.

Last year, Hapilon -- who headed a major faction of Abu Sayyaf -- was designated by ISIS as the terrorist organization's emir for Southeast Asia and commander of the so-called Brigade of the Migrant based on the southern island of Mindanao and made up of fighters from Malaysia, Indonesia and the Philippines.

Though a various disparate militants have operated in the region for years, analysts told CNN that Hapilon's elevation to ISIS emir led to greater unity between the various organizations in the area.

The FBI had offered a reward of up to $5 million for information leading directly to Hapilon's apprehension or conviction for a litany of alleged crimes, including hostage taking, murder, and terrorist activities.

Despite the hefty bounty on his head -- and pursuit by US and Philippines special forces -- Hapilon managed to avoid capture for 16 years.

During that period, the tactics deployed by Abu Sayyaf grew more extreme and more deadly.

In 2004, the group bombed a passenger ferry in Manila Bay, killing 116 people, while in 2014, Abu Sayyaf militants attacked civilians celebrating the end of Ramadan, in Talipao, in Sulu province in the far south west of the country, killing at least 21, according to the US State Department

JUST WATCHED ISIS gains foothold in Philippines Replay More Videos ... MUST WATCH ISIS gains foothold in Philippines 02:53

The end of fighting?

The death of Hapilon and Omar Maute may come to signal the final stage of what has been a protracted and destructive standoff in Marawi between ISIS-linked militants in Marawi and the government, but it's feared that fighters could resort to traditional types of terror attacks -- a possibility President Duterte warned of Wednesday

"They will not disappear. They will regroup anywhere and everywhere," Duterte said.

"Be patient. This terrorism inspired by ISIS will not go in about seven to 10 years ... terrorism is a deadly movement to confront us and our children. Your children will encounter this. It will reach your retirement age. So just be prepared for that," he said.

Heydarian, the security analyst, said the Philippines must step up its intelligence-gathering operations to stop these types of attacks in the planning phase.

ISIS will "try its best to show they're still alive and kicking. You can imagine what kind of things they'll be thinking about to send that message across," he said.