A Bangladeshi police officer gestures during a rescue operation Saturday morning during a deadly standoff with gunmen at a restaurant in the upscale diplomatic enclave in Dhaka, the capital. (Str/AFP/Getty Images)

Bangladesh just realized one of its worst fears. The South Asian nation, no stranger to either vicious politics or targeted Islamist killings, this weekend experienced its deadliest and most sophisticated attack yet, in what appeared to be a calculated blow against the country’s elite, including its foreign residents.

The Holey Artisan Bakery and its restaurant, known as O’Kitchen, is a modest establishment that represents global dreams — and wallets. Located in the Bangladeshi capital’s diplomatic quarter, it has a handsome garden featuring some of the last green space in the city and is the only place in the country of 160 million to sell sourdough bread and Greek yogurt. Late Friday, 40 or so customers were in the restaurant, along with a large contingent of employees, including two foreign chefs.

Shortly after 9 p.m, a group of gunmen stormed the building, according to witnesses, precipitating a 12-hour standoff that left at least 28 people dead, including 20 hostages, six of the seven suspected gunmen and two police officers. Thirteen hostages were rescued, and at least one assailant was reportedly taken into custody.

Most of the slain hostages are believed to be foreigners. State Department officials confirmed Saturday that an American was among them, although the victim’s identity was not released. The dead included three students at U.S. colleges, those schools confirmed: Faraaz Hossain and Abinta Kabir of Emory University’s Oxford College and Tarushi Jain, a 19-year-old Indian student at the University of California at Berkeley.

Nine Italians and seven Japanese were also killed, the Associated Press reported their governments as saying, with one Italian still unaccounted for. According to local news reports, the gunmen divided people by nationality and asked people to recite verses of the Koran, sparing those who could.

An online media group linked to the Islamic State claimed that the militant organization carried out the attack, according to the SITE Intelligence Group, which monitors jihadist activity online. The extent of the Islamic State’s operational presence in majority-Muslim Bangladesh remains unclear, however.

Home Minister Asaduzzaman Khan said, however, that the attackers were members of a banned domestic militant group, not the Islamic State.

“They are all Bangladeshis. They are from rich families, they have good educational background,” Khan said of the attackers, according to the Associated Press.

Sumon Reza, a restaurant employee, told reporters that as the attack began, the assailants shouted “Allahu Akbar!” (God is great) and fired into the air. “They didn’t shoot or hit anybody,” Reza said. “Just to create fear. The guests were all lying on the ground under the chairs and tables. And we [employees] escaped in whichever safe way we could.”

Before long, security forces arrived, only to be met by a hail of bullets from the roof, according to a weary-eyed infantryman Saturday morning. Residents said an hours-long exchange of gunfire followed that echoed through the upscale neighborhood.

After phalanxes of security personnel surrounded the building, the shooting subsided and negotiations got underway. It was then that the horrors really began for the hostages. At one table sat eight Japanese consultants with the aid organization JICA; others were occupied by Italian garment entrepreneurs or young friends who had studied at the American school in Dhaka. Locals were also there, enjoying the start of the Muslim holiday of Eid al-Fitr.

A military spokesman, Brig. Gen. Nayeem Ashfaque Chowdhury, told reporters that “most of the victims were killed brutally with sharp weapons.” In video footage shot from a nearby building, a young man can be seen patrolling the restaurant’s interior, carrying what appears to be a foot-long blade. According to local media, those who couldn’t recite the Koran had their throats cut. The Islamic State shared on Twitter photos purporting to show victims lying in pools of blood.

U.S. officials are in contact with authorities in Bangladesh, according to a White House statement.

“Our deepest condolences go out to the families and loved ones of those killed, and we hope for a speedy recovery for those wounded,” the statement said. “This is a despicable act of terrorism.”

“It was an extremely heinous act,” Prime Minister Sheikh Hasina said in a televised statement, according to the BBC. “What kind of Muslims are these people? They don’t have any religion. My government is determined to root out terrorism and militancy from Bangladesh.”

Bangladesh has long questioned the scope of the militant group’s presence in the country. Western analysts, however, are adamant that it has been involved in operations there, citing as its most notorious local franchise a group known as Jamaat-ul-Mujahideen Bangladesh, or JMB. Formed by returning militants who had fought the Soviets in Afghanistan in the 1980s, the group has sought an Islamic revolution for more than a decade. According to cables released by WikiLeaks, it has also acted on behalf of politicians from the now-opposition Bangladesh Nationalist Party, sending its thugs to kill leftists to help local politicians control their fiefdoms. JMB was alleged to be behind a string of targeted killings of foreigners, including the assassination of an Italian aid worker named Cesare Tavella last November close to the Holey Bakery.

Nor is JMB alone. In 2013, a hitherto unknown group called Ansarullah Bangla Team cropped up, meting out what it described as justice to nonconformists such as atheists and bloggers. Many of the young bloggers who were targeted had campaigned for stiffer sentences for Islamist politicians accused of war crimes in Bangladesh’s war of independence in 1971. The group made its mark when, in early 2015, it claimed to have hacked to death the prominent Bangladeshi American skeptic Avijit Roy. More killings followed, typically in ambushes by machete-wielding youths. The group is thought to be aligned with al-Qaeda in the Indian Subcontinent and inspired by the late Yemeni American terrorist Anwar al-Awlaki and his Web-savvy jihad.

By Saturday morning, Bangladesh had mobilized its crack troops, and in the humid air, hundreds of soldiers, commandos and paramilitary fighters gathered on what had been quiet residential streets. In camouflaged armored personnel carriers, commandos stormed the bakery premises, and in an operation lasting all of 13 minutes, entered the restaurant and overpowered the terrorists.

Soldiers collapsed with exhaustion in aging armored vehicles as the siege ended, explosions ripping through the air as a few last improvised explosive devices were disposed of. The incident was over, but many questions remain for a government that as recently as last month arrested 14,000 terrorism suspects in a sweep aimed at halting the wave of killings that has blighted the country.