Seven militants who killed 20 people at a restaurant in Dhaka were local Bangladeshis and authorities had tried before to arrest five of them, police said, as investigators probed for possible links with international Islamist extremist groups.
The gunmen stormed the upmarket Holey Artisan Bakery and the O'Kitchen restaurant in the diplomatic zone late on Friday, before killing mostly non-Muslim hostages, including at least nine Italians, seven Japanese, an Indian and an American.
Islamic State claimed responsibility, warning citizens of "crusader countries" that their citizens would not be safe "as long as their aircraft are killing Muslims", the group said in a statement. It also posted pictures of five fighters grinning in front of a black flag who it said were involved in the attack, according to the SITE monitoring website.
The claims have not been confirmed, but Bangladesh Home Minister Asaduzzaman Khan told Reuters late on Saturday that neither Islamic State nor al-Qaeda was involved. He reiterated the government's line that home-grown militants were responsible for a spate of killings in the country over the past 18 months.
"This was done by JMB," Khan said, referring to Jamaat-ul-Mujahideen Bangladesh, which claims to represent Islamic State in Bangladesh.
Analysts say that as Islamic State loses territory in Iraq and Syria and its finances get drained, it may be trying to build affiliates in countries such as Bangladesh for jihadists to launch attacks locally and cheaply.
Deputy inspector general of police, Shahidur Rahman, told Reuters on Sunday authorities were investigating any connection between the attackers and trans-national groups such as Islamic State or al-Qaeda.
He said the militants were mostly educated and from rich families, but declined to give any more details.
National police chief Shahidul Hoque said all the gunmen were Bangladeshi.
"Five of them were listed as militants and law enforcers made several drives to arrest them," Hoque told reporters in Dhaka late on Saturday.
Whoever was responsible, the attack marked a major escalation in violence by militants who have demanded Islamic rule in Bangladesh, whose 160 million people are mostly Muslim.
Previous attacks have mostly singled out individuals advocating a secular or liberal lifestyle or religious minorities.
Friday night's attack, during the final days of the Muslim fasting month of Ramadan, was more coordinated than the previous assaults.
Gunmen singled out foreigners as soon as they stormed through the doors of the restaurant popular with expatriates. They ordered all Bangladeshis to stand up before the killing began, a source briefed on the investigation said. The Bangladeshis were later told to close their eyes and recite verses from the Koran and one militant cursed at a Bangladeshi for eating with non-Muslims during Ramadan, the source said.
The Islamic State-affiliated Amaq news agency claimed in a report on Saturday the militants identified and released Muslim patrons from the Dhaka restaurant, SITE said.
The victims also included at least three Bangladeshis or people of Bangladeshi descent.
The militants hacked most of their victims with machetes, leaving their bodies to bleed over the floor.
A 12-hour standoff with security forces ended when around 100 commandos stormed the building, killing six of the militants and capturing a seventh after attempts at negotiations proved fruitless, authorities said. They recovered explosives and sharp weapons from the scene.
It was not clear if the attackers had made any demands.
Up until Friday's attack, authorities had maintained no operational links exist between Bangladeshi militants and international jihadi networks. Bangladesh has blamed JMB and another home-grown outfit for the wave of grisly killings over the past year and a half.
One line of inquiry being pursued is whether the restaurant attackers received any guidance from Islamic State or al Qaeda, an official in Bangladesh's counter-terrorism wing said.
"Pictures (uploaded on Twitter) indicate they might have been encouraged by ISIS (Islamic State) activities abroad," said Muhammad Zamir, a former senior Bangladesh foreign ministry official. "But this does not show a direct link to ISIS. This is exactly what was done and disputed later in the case of the Orlando attack."
He was referring to the killing of 49 people last month by a man who pledged allegiance to Islamic State.
Friday's attack in Dhaka was the worst since 2005, when JMB set off a series of bombs throughout Bangladesh in the space of an hour killing at least 25 people, mostly judges, police, and journalists.
The authorities executed six top JMB leaders in March 2007 and police have continued to hunt for group members, often detaining suspected militants following intelligence tips.
In February, Bangladesh police arrested three JMB members suspected of killing a Hindu priest.
Islamic state has claimed responsibility for a series of other attacks in Bangladesh in recent months since first taking credit for a killing in September last year. An Italian missionary was shot and wounded in the neck last November. Another Italian and a Japanese citizen were killed in attacks at the end of September and early October last year.
In a run-down government hospital in Dhaka, two police officers who were on patrol duty on Friday night received treatment for gunshot wounds, with bandages and plasters on cheeks and legs. Behind their beds, a sheet of paper carried details of their wounds.
Struggling to speak, 30-year-old officer Pradip, who gave just one name, recalled rushing to the spot after receiving a wireless message that night. A blood-smeared man lay in front of the restaurant, shouting "save me, save me".
The police officers called for backup after they were shot at from inside the restaurant.
"At some point I felt blood was rolling down my cheek," Pradip said. "We did respond with fire and the attackers stopped. We then rescued the man, who was the driver of some of the Japanese citizens who were inside."
After meeting the officers in the hospital, national police chief A.K.M. Shahidul Hoque told Reuters they had gleaned some preliminary details on the identities of the attackers, but he declined to give details.
The seven Japanese killed were working on projects involving the Japan International Cooperation Agency, an overseas aid agency, Japan's Chief Cabinet Secretary Yoshihide Suga said on Saturday.
Six of them were in Dhaka to work on a metrorail project, Bangladesh's communication minister, Obaidul Quader, said.
Italian media said several of the Italians victims worked in Bangladesh's $26 billion garment sector, which accounts for 80 percent of its exports.
Prime Minister Sheikh Hasina announced two days of national mourning beginning on Sunday and said the country would stand up and fight the "terror threat."
Follow VICE News on Twitter: @vicenews