When Marawi, a once-little known city in the southern Philippines, was overrun by militants allied to IS in May, it brought the spectre of radical Islamist insurgency to Australia’s doorstep.
Some 500 people, including 39 civilians, have been killed and about 260,000 residents displaced in the conflict, which erupted after a failed attempt on May 23 to arrest a Filipino militant commander backed by IS.
The gains made by the Abu Sayyaf and Maute groups, and the inability of the Philippines Army to retake the city, have raised fears an IS-inspired insurgency could gain a foothold and spread to other parts of Southeast Asia.
What are the origins of the conflict?
The southern Philippines has been plagued for decades by insurgency and lawlessness.
When Spanish colonialists landed in the country in the mid-16th century and pushed Muslims to the south, they called them 'Moros', from the Spanish word for 'Moors'.
Moro rebel groups have resisted Manila’s control for hundreds of years.
Multiple peace pacts with Moro groups have collapsed or run into delays over the second half of the 20th century, consigning Mindanao to economic neglect and poverty, and fuelling a culture of insurgency and banditry.
In 2016, five separate pro-IS groups operating in the southern Philippines swore allegiance to former Abu Sayyaf commander Isnilon Hapilon after he was endorsed by IS as emir for Southeast Asia.
The alliance now forms the basis of the Marawi insurgency.
How did the fighting start?
Clashes erupted in Marawi city following an unsuccessful army raid to capture commander Isnilon.
Militants loyal to him stormed through the streets of Marawi, taking schools, hospitals and other public buildings. President Rodrigo Duterte declared martial law in the Mindanao region hours later.
Joseph Franco, a Filipino counter-terrorism expert at Singapore’s Nanyang Technological University, said Marawi was the "perfect storm" for an urban insurrection.
Many of the bunkers and tunnels used by the militant groups have long been part of the landscape.
“Those features in the urban terrain predate Maute, ISIS and even Al Qaeda. So in short, the Mautes had a ready made fortified playground,” he told SBS World News.
Who are the main players?
The Maute group and Abu Sayyaf are the two main radical Islamist groups fighting in Marawi.
Abu Sayyaf, which is made up of factions, is most well known for carrying out bombings and kidnappings for ransom in the archipelago.
Experts say it is unclear why Isnilon was endorsed by IS in early 2016, but it led to the unification of pro-IS groups behind him.
The Mautes are the biggest and most dangerous IS-allied group in Marawi. They also appear to be the ones making the major military and operational decisions, said terrorism expert Sidney Jones, director of the Jakarta-based Institute for Policy Analysis of Conflict.
Farhana Maute, 60, is the matriarch of the wealthy and well-connected Muslim family. Brothers Omar and Abdullah Maute, who were both educated in the Middle East, command the group’s forces.
The Mautes have family ties to Moro Islamic Liberation Front (MILF), historically one of the main rebel groups in Mindanao.
In November 2016, Maute rebels took over a small town on the island. They also carried out a bombing in Davao city two months earlier.
Ms Jones said, in retrospect, it was clearly a trial run for what would later happen in Marawi.
"All this time, the Philippine security authorities didn't see anything particularly amiss. To them, this was just another same-old, same-old insurgent group, splinter group," she told SBS World News.
What is Philippines President Rodrigo Duterte's plan?
President Duterte, the outspoken former mayor of Davao, another city in Mindanao, has said he is deeply saddened by the crisis and promised Marawi would be rebuilt.
He said he had cousins who were members of the Maute group, one of which had been killed, and his decision to declare martial law on Mindanao was justified because he was aware of exactly what the extremists would do.
Duterte has vowed to crush the extremists occupying Marawi and ruled out negotiating with them.
Military aircraft have dropped bombs on the town while ground forces are trying to advance house to house.
Why is the conflict of concern to the region?
The early success of the militant groups in Marawi and the involvement of foreign fighters has stoked fears an IS-inspired insurgency could gain a foothold in Southeast Asia.
For Malaysia and Indonesia, whose nationals are among the Maute group fighting in Marawi, the situation is particularly worrisome.
Both countries have agreed to step up joint patrols and intelligence sharing with the Philippines to halt the spread of IS influence among their Muslim-majority nations.
Jones said there are strong links between insurgents in Marawi and exremists in Indonesia and Malaysia.
"More importantly, they also have links between Indonesians and Malaysians in Syria," she said.
"There has been direct communication between Indonesians and Malaysians in senior leadership roles within the Southeast Asian community in Isis, in Raqqa in particular, with the people holding Marawi."
Foreign fighters from the region have travelled to the Philippines for training in the past, but the rise of social media as a recruitment tool has raised the stakes.
IS has proved adept at recruiting fighters to the Middle East via social media and last month told foreign fighters to go to the Philippines if they could not reach Syria or Iraq.
Why is Australia getting involved?
Australia announced it was sending advanced intelligence-gathering P-3 Orion aircraft to fly over southern parts of the Philippines on June 23.
Defence Minister Marise Payne said the regional threat from terrorism, in particular IS and foreign fighters, is a direct threat to Australian interests.
The United States confirmed in early June it was assisting the Philippines army.
During a visit to Australia in June, US Commander Lieutenant General David Berger urged Australia to take greater involvement in the fight against IS in south-east Asia.
He said there was potential for the Philippines insurgency to spread and expects Australian forces could soon join American troops fighting Islamic extremists in the region.