In an attack claimed by the Islamic State group, a powerful first blast shattered pews, broke windows and left bodies strewn inside the cathedral in the Catholic-majority nation's restive south as mass was being celebrated.
Moments later a second explosion outside killed troops who were rushing to help the wounded in the smoking and heavily damaged church on Jolo, which is overwhelmingly Muslim.
It is one of the deadliest bomb attacks to strike the insurgency-plagued southern Philippines in years, and shows militants in the region are still a threat despite recent steps toward peace, experts said.
The bloodshed came less than a week after voters' decisive approval of giving Muslims in the south more control over their own affairs, which sparked hopes of quelling long-time separatist violence.
"Just because the (referendum) has passed does not mean that things are going to get better overnight," said Gregory Wyatt, director for business intelligence at PSA Philippines Consultancy.
"There are still militant groups that will continue to be active and pose a security threat," he told AFP.
Pope Francis, speaking in Panama, expressed his "strongest reprobation" for the violence. Once again, he said, "the Christian community has been plunged into mourning."
Bishop Angelito Lampon, who previously served in Jolo, said Sunday's attack may be the worst, but was certainly not the first on the church.
"In my 20 years there from 1998 to last week, there were seven hand grenades lobbed into our cathedral," he told AFP. "Fortunately there was just a little damage and no casualties."
- IS group claim -
The Islamic State group claimed responsibility for the attack, issuing a formal communique saying two suicide bombers had detonated explosive belts, according to the SITE Intelligence Group which monitors jihadist activities.
But a military report said the second bomb was left in the utility box of a motorcycle in the parking area outside the church.
Manila swiftly vowed to hunt down the attackers.
"We will pursue to the ends of the earth the ruthless perpetrators behind this dastardly crime," presidential spokesman Salvador Panelo said in a statement. "The law will give them no mercy."
Five soldiers, a member of the coast guard and 12 civilians were among the dead while 83 other people were wounded, said regional military spokesman Lieutenant Colonel Gerry Besana.
The regional police chief Graciano Mijares put the toll slightly higher at 20 dead, lower than a figure of 27 he gave initially.
Pro-IS militants are among multiple armed networks based in the strife-torn region of Mindanao.
President Rodrigo Duterte put the southern Philippines under martial rule after pro-IS militants seized the southern city of Marawi in May 2017.
A bombing the previous year that ripped through a bustling night market in Duterte's hometown left 15 dead, and was blamed on the Maute gang of Islamist militants that pledged allegiance to IS.
Before the IS jihadists' claim emerged, Besana said the notorious Abu Sayyaf kidnap-for-ransom group could be behind the blasts, but added officials were "not discounting the possibility that there are other perpetrators".
The remote island of Jolo is a base of the Abu Sayyaf, which is blamed for deadly bombings, including an attack on a ferry in Manila Bay in 2004 that claimed 116 lives in the country's deadliest terror assault.
- 'Peace must prevail' -
Neither the hardline factions aligned with IS nor the Abu Sayyaf were part of the decades-long peace process with the nation's largest separatist group, Moro Islamic Liberation Front, that culminated January 21 with the resounding approval of a new Muslim led-region in the south.
Rebels and the government in Manila hope the new so-called Bangsamoro area will finally draw the investment needed to pull the region from the brutal poverty that makes it a hotspot for radical recruitment.
Despite Sulu province -- which includes Jolo -- voting against creating the new region, the area will still be part of the Bangsamoro.
The timing of Sunday's bombs raised questions on whether the attack was meant to derail the peace process.
National Security Adviser Hermogenes Esperon said "extremist criminals" plotted the bombings.
"We will not allow them to spoil the preference of the people for peace," Esperon said. "Peace must prevail over war."