DHAKA, Bangladesh (AP) — The hostages were given a test: recite verses from the Quran, or be punished, according to a witness. Those who passed were allowed to eat. Those who failed were slain.

The dramatic, 10-hour hostage crisis that gripped the Bangladesh’s diplomatic zone ended Saturday morning with at least 28 dead, including six of the attackers, as commandos raided the popular restaurant where heavily armed attackers were holding dozens of foreigners and Bangladeshis prisoner while hurling bombs and engaging in a gunbattle with security forces.

The attack marks an escalation in militant violence that has hit the traditionally moderate Muslim-majority nation with increasing frequency in recent months, with the extremists demanding the secular government revert to Islamic rule. Most previous attacks have involved machete-wielding men singling out individual activists, foreigners and religious minorities.

But Friday night’s attack was different, more coordinated, with the attackers brandishing assault rifles as they shouted “Allahu Akbar” (God is Great) and stormed the Holey Artisan Bakery in Dhaka’s Gulshan area while dozens of foreigners and Bangladeshis were dining out during the Ramadan holy month.

The gunmen, initially firing blanks, ordered restaurant workers to switch off the lights, and they draped black cloths over closed-circuit cameras, according to a survivor, who spoke with local TV channel ATN News. He and others, including kitchen staff, managed to escape by running to the rooftop or out the back door.

But about 35 were trapped inside, their fate depending on whether they could prove themselves to be Muslims, according to the father of a Bangladeshi businessman who was rescued Saturday morning along with his family.

“The gunmen asked everyone inside to recite from the Quran,” the Islamic holy book, according to Rezaul Karim, describing what his son, Hasnat, had witnessed inside. “Those who recited were spared. The gunmen even gave them meals last night.”

The others, he said, “were tortured.”

Detectives were questioning his son and his family along with other survivors as part of the investigation on Saturday, as scattered details of the siege emerged. Authorities were also interrogating one of the attackers captured by commandos in dramatic morning rescue.

It was not immediately clear whether the attackers had a specific goal, and Bangladesh authorities would not say if they had made any demands.

The 20 hostages killed included nine Italians, seven Japanese, three Bangladeshis and one Indian, government sources said, as details of the bloodshed began trickling from other capitals worldwide.

“All the hostages were killed last night. The terrorists used sharp weapons to kill them brutally,” said Brig. Gen. Nayeem Ashfaq Chowdhury of the Army Headquarters in a news conference Saturday night.

Another two Bangladeshi police officers also died from injuries sustained while exchanging gunfire with the attackers Friday night.

In New Delhi, Foreign Minister Sushma Swaraj said she was “extremely pained to share that the terrorists have killed Tarushi, an Indian girl who was taken hostage in the terror attack in Dhaka.”

Eighteen-year-old Tarushi Jain had been on holiday from her studies at the University of California, Berkeley. She was in Dhaka visiting her father, who has run a garment business in the country for the past 15 or 20 years, according to Indian government sources, who were not authorized to speak with media and so requested anonymity.

But another Indian citizen, a doctor who spoke Bengali and could pass himself as a Bangladeshi, was released unharmed, a government source said.

A Bangladeshi woman Ishrat Akhond was also among the dead. She had been holding a dinner meeting with Italian businessmen when she was killed in the siege, according to three of her friends who did want to be named for fear of reprisal. One told the AP, “she was such a loving person, such a good friend.” Others posted photographs and messages of disbelief and condolences on her Facebook page.

Another victim, Abinta Kabir, had been a student at Emory University’s campus in Oxford, Georgia, and was visiting family and friends on a vacation, the university said in an email to employees.

Ten of 26 people who were wounded Friday night when the militants opened fire were in critical condition, and six were on life support, according to hospital staff. The injuries ranged from broken bones to gunshot wounds. Most of them were police officers, but one was a civilian. Hospital staff refused to provide any details of their condition on Saturday.

In the end, paramilitary troops managed to rescue 13 hostages, including one Argentine, two Sri Lankans and two Bangladeshis, according to Lt. Col. Tuhin Mohammad Masud, commander of the Rapid Action Battalion that conducted the rescue operations. Japan’s government said one Japanese hostage was also rescued with a gunshot wound.

The commandos launched the morning rescue operation after the attackers did not respond to calls for negotiation, Masud said. As the troops, wearing flak jackets and helmets and armed with automatic weapons, moved in on the restaurant at 7:40 a.m., local TV stations reported the sound of gunfire and explosions. At least seven armored vehicles and ambulances stood by.

The commandos killed six of the attackers and recovered explosive devices and sharp weapons from the scene, said Chowdhury of the Army Headquarters.

“Because of the effort of the joint force, the terrorists could not flee,” Prime Minister Sheikh Hasina said in a nationally televised speech, vowing to fight militant attacks in the country and urged people to come forward.

The audacious attack came during Ramadan, when devout Muslims fast during the day and eat after dark. Many left the city of more than 10 million people for a nine-day public holiday with families to celebrate Eid al Fitr festival with families.

“Anyone who believes in religion cannot do such an act,” Hasina said. “They do not have any religion, their only religion is terrorism.”

She announced two days of national mourning for the dead.

The Islamic State group claimed responsibility, saying it targeted the citizens of “Crusader countries” in the attack. The statement was circulated by IS supporters on the Telegram messaging service and resembled previous statements by IS. It was not immediately clear if its leadership in Syria and Iraq was involved in the planning the attack. The Amaq news agency, affiliated with IS, also posted photos purportedly showing hostages’ bodies, though the authenticity of the images could not be confirmed.

The government did not directly comment on the IS claim but has denied in the past that the extremist group has a presence in Bangladesh. Hasina’s government instead has accused her political enemies of orchestrating the violence in order to destabilize the nation – which the opposition denies.

The government has cracked down on domestic radical Islamists by making scores of arrests. It has blamed local terrorists and opposition political parties – especially the main opposition Bangladesh Nationalist Party and its Islamist ally Jamaat-e-Islami.

But the attacks have continued, with about two dozen atheist writers, publishers, members of religious minorities, social activists and foreign aid workers slain since 2013. Earlier on Friday, a Hindu temple worker was hacked to death by at least three assailants in southwest Bangladesh. IS and and al-Qaida affiliates have claimed responsibility for many of those attacks.

The escalating violence leading up to the unprecedented hostage crisis has raised fears that religious extremists are gaining a foothold in the country, despite its traditions of secularism and tolerance. That the attackers targeted a popular restaurant in the heart of the diplomatic quarter of Bangladesh’s capital signaled a change in tactics. The restaurant overlooking a lake serves Spanish food and is patronized by residents of Gulshan, an affluent neighborhood where most of the foreign embassies are located.

In Washington, a White House official said President Barack Obama was briefed on the attack by his chief counterterrorism adviser Lisa Monaco. The president asked to be kept informed as the situation develops, said the official, who was not authorized to speak publicly about the president’s meetings.

State Department spokesman John Kirby says the U.S. had offered its assistance to bring those responsible to justice.