DHAKA • The cook was crouching in a washroom, taking refuge from the gunmen who had invaded the Holey Artisan Bakery, when he understood that there was a logic behind the killing: The people in the restaurant were being sorted.
"Bengali people, come out," one gunman shouted. When the cook, Mr Sumir Barai, and eight other men opened the bathroom door, trembling, they saw two young men, clean-shaven and dressed in jeans and T-shirts. "You don't need to be so tense," one of the men said. "We will not kill Bengalis. We will kill only foreigners."
At that, Mr Barai's gaze flicked to the floor of the restaurant, where he could see six or seven bodies, apparently shot and then sliced with machetes. All appeared to be foreigners.
The gunmen, he said, seemed eager to see their actions amplified on social media: After killing the patrons, they asked the staff to turn on the restaurant's wireless network. Then they used customers' phones to post images of the bodies on the Internet.
Last Friday night's assault on the Holey Artisan Bakery in the diplomatic district of Dhaka, in which at least 20 mostly foreign hostages and two police officers were killed, marks a scaling-up of ambition and capacity for Bangladesh's Islamist militancy, which has until now carried out pinpoint assassinations, mostly of critics of Islam and members of religious minorities.
The attack suggests that Bangladesh's militant networks are internationalising, a key concern as the United States seeks to contain the growth of the Islamic State in Iraq and Syria (ISIS).
Bangladesh's 160 million people are almost all Sunni Muslims, including a demographic bulge under the age of 25. This makes it valuable as a recruiting ground for ISIS, now under pressure in its core territory of Iraq and Syria.
Western intelligence officials have been watching the organisation pivot to missions elsewhere in the world, launching attacks on far-flung civilian targets that are difficult to deter with traditional military campaigns.
"We need to take serious stock of the overall threat," said Mr Shafqat Munir, a research fellow at the Bangladesh Institute of Peace and Security Studies. "There were all sorts of warnings and signs... But I don't think anyone expected anything as audacious and large-scale as this."
Even as they killed the foreigners, the attackers were unfailingly polite and solicitous with the restaurant staff and other Bangladeshis, Mr Barai said.
He recalls being puzzled by the attackers, who spoke cosmopolitan Bengali, and even some English, when conversing with the foreigners.
"They were all smart and handsome and educated," he said. "If you look at those guys, nobody could believe they could do this."
In the pre-dawn hours, they lectured their captives on religious practices, instructing the kitchen staff to say regular prayers and study the Quran.
A senior police official said the police tried unsuccessfully to establish contact with the gunmen, who never passed on any demands.
During the long hours that passed inside the restaurant, the gunmen made it clear that they expected to die, Mr Barai said.
They were getting ready to walk out of the door, he said, when the commandos stormed the restaurant early in the morning.
NEW YORK TIMES, REUTERS