It was meant to be a "surgical operation" to capture one of the world's most wanted terrorists, who was hiding and wounded in a southern Philippine city. But it went spectacularly wrong.
Three days later, Marawi, the center of Islam in the mainly Catholic Asian nation was swarmed by tanks, attack helicopters and thousands of troops fighting terrorists holed up in homes and buildings.
President Rodrigo Duterte had also declared martial law across the southern third of the country to quell the crisis, while many of the 200,000 residents had fled, and security forces had lost their target: Isnilon Hapilon.
Forces had initially been confident they would capture or kill the elusive Hapilon, regarded by the United States as one of the world's most dangerous terrorists. The US government offers a $5-million bounty for his capture.
The military had for months been conducting offensives against Islamist militants in nearby mountains, and came close to killing Hapilon during a bombing raid in January.
After receiving intelligence that he had come to Marawi for medical treatment and was hiding in a house, a small group of security forces conducted what two military spokespeople described as a "surgical operation" to get him.
But, even though the region is a known hotbed of Islamist militants, the troops were taken by surprise when dozens of gunmen emerged to defend Hapilon, then go on a deadly rampage throughout the city.
"We had been pummeling them in the mountains, but were caught unaware when they entered Marawi," Defense Secretary Delfin Lorenzana conceded in a briefing to reporters on Wednesday.
Compounding the problem was the support for the gunmen from locals, connected by clan ties.
"The problem here is they have a lot of relatives inside Marawi city," Lorenzana said.
Five soldiers, two policemen and 13 militants have died in the ensuing clashes, according to authorities, with up to 40 gunmen still believed to be hiding in the city holding a priest and other people abducted from a Church to serve as human shields.
If Hapilon does escape, it would be a huge blow for the Philippine authorities in their efforts to stamp out what Duterte has said is a fast-rising threat from the Islamic State (IS) group.
The government and security analysts consider Hapilon the linchpin of an effort to unite various small Muslim armed groups in the country's lawless south and neighboring countries under the black IS flag.
Hapilon, 51, initially gained notoriety as leader of the Abu Sayyaf, a US-listed terrorist organisation that was founded with seed money from Al-Qaeda in the early 1990s.
The Abu Sayyaf, based on remote, Muslim-populated islands in the far south of the Philippines, has earned many millions of dollars by kidnapping hundreds of Filipinos and foreigners, and demanding ransoms.
In 2001, he helped lead the abduction from a western Philippine resort island of a group of local and foreign tourists. Two American hostages eventually died, one of whom was beheaded.
The Abu Sayyaf is also blamed for the Philippines' deadliest terror attacks, including the 2004 bombing of a ferry in Manila that claimed 116 lives.
In mid-2014, Hapilon, an engineering graduate from the University of the Philippines, showed up in a YouTube video as one of the first Islamist militant leaders in the Philippines to pledge allegiance to IS.
Institute for Policy Analysis of Conflict director Sidney Jones, an expert on Asian jihadist movements, said Hapilon was endorsed by the IS as its "amir", or top leader for Southeast Asia.
Lorenzana said IS leaders in the Middle East had ordered Hapilon to move off his tiny island base of Basilan and into more populated areas of the southern Philippines near Marawi "to increase the mass base" of IS.
Hapilon's escape on Tuesday has had broader implications than IS's prospects in the Philippines, with Duterte citing the ensuing violence as justification to declare martial law over Mindanao and threaten military rule for the rest of the country.