Bangladesh began two days of national mourning Sunday after 20 hostages were slaughtered at a restaurant as the government insisted the attackers were homegrown jihadists and not followers of the Islamic State group.
Prime Minister Sheikh Hasina decreed the mourning period as she vowed to drag Bangladesh back from the brink, warning of a concerted bid to turn one of the world's most populous nations into a failed state.
Amid mass condemnation of the killings in Dhaka, whose victims included 18 foreigners, the Islamic State group said it had targeted a gathering of "citizens of crusader states" on Friday night at a Western-style cafe.
But a government minister insisted the killers, six of whom were gunned down at the end of the siege, were members of a homegrown militant outfit and had no links to international jihadist networks.
"They are members of the Jamaeytul Mujahdeen Bangladesh," Home Minister Asaduzzaman Khan told AFP, referring to a group which has been banned in Bangladesh for more than a decade.
"They have no connections with the Islamic State."
As well as the 20 slain hostages whose bodies were found amid pools of blood after commandos stormed the cafe to end the siege, two policemen were also shot dead in a fierce gunbattle at its outset.
Six gunmen were shot dead by the commandos at the final stages of the siege at the Holey Artisan Bakery cafe but one of the hostage-takers was taken alive and was being interrogated by Bangladeshi intelligence.
Security officials said most of the victims were slaughtered with sharpened machete-style weapons.
Hasina's government has previously blamed a string of deadly attacks against religious minorities and foreigners on domestic opponents but the latest will heighten fears that IS's reach is spreading.
"Islam is a religion of peace. Stop killing in the name of the religion," Hasina said in an impassioned televised address to the nation.
The 68-year-old premier said the people behind the attacks were trying to ruin Bangladesh, a mainly Muslim nation of 160 million people.
"By holding innocent civilians hostage at gunpoint, they want to turn our nation into a failed state," she said.
Analysts say that the government is wary of acknowledging that groups such as IS or Al-Qaeda have gained a foothold in Bangladesh over fears that it will frighten off foreign investors.
But Shahedul Anam Khan, an analyst for the Dhaka-based Daily Star, said the attack meant the government could no longer plausibly deny that international jihadist groups were active in Bangladesh.
"While one is not sure that these people are organically linked to the international extremist groups, the government must own up to the reality that the footprints of the IS in this country is very real and no amount of denying can alter the fact," he wrote.
Flags were being flown at half-mast in government offices while prayer services were being held across the country.
Agony in Italy
Italy was mouring the loss of nine of its nationals in the attack while seven Japanese were also killed.
Japanese Prime Minister Shinzo Abe spoke of his "profound anger that so many innocent people have lost their lives in the cruel and nefarious terrorism" with Pope Francis also joining the welter of condemnation.
The other victims included an American citizen and a 19-year-old Indian who was studying in California.
A Bangladeshi survivor of the massacre told how the attackers split the diners into groups of foreigners and locals, making clear that their targets were non-Muslims.
"They kept saying: 'Do not worry, we are here to kill foreigners and non-Muslims. You should pray to God, pray five times a day'," the unnamed survivor told the Dhaka Tribune newspaper.
Home minister Khan said that all of the attackers were well-educated and most came from wealthy families.
"They are all highly educated young men and went to university. No one is from a madrassa," the minister said.
Asked why they would have become Islamist militants, Khan said: "It has become a fashion."
The attack, by far the deadliest of a recent wave of killings claimed by IS or a local Al-Qaeda offshoot, was carried out in the upmarket Gulshan neighbourhood which is home to the country's elite and many embassies.
Last month authorities launched a crackdown on local jihadists, arresting more than 11,000 people but critics allege the arrests were arbitrary or designed to silence political opponents.
Bangladesh's main Islamist party has been banned from contesting polls and most of its leaders have been arrested or else executed after recent trials over their role in the 1971 war of independence from Pakistan.