The father of one of the survivors said his son was held hostage for 12 hours after being separated from the foreign victims.
Rezaul Karim told Bangladesh's Daily Star newspaper: “The gunmen were doing a background check on religion by asking everyone to recite from the Quran.
“Those who could recite a verse or two were spared. The others were tortured.”
An Isis-affiliated propaganda agency released photos from inside the restaurant during the raid, appearing to showing the bodies of women and men on the floor in pools of blood by overturned tables and chairs.
Mr Karim said that Bangladeshi nationals who were able to say selected passages of the Muslim holy book were treated well and given food.
His son Hasnat was among 13 hostages freed after armed police and Bangladeshi troops raided the Holey Artisan Bakery café on Saturday morning.
Army Brigadier General Nayeem Ashfaq Chowdhury said most of the hostages were “killed mercilessly by sharp weapons” but local reports of beheadings were unconfirmed.
The so-called Islamic State claimed responsibility for the attack, saying its “commandos” targeted the restaurant because it was “frequented by Crusaders” – a term it uses to refer to foreigners mostly from the West.
A statement from the group said it had identified and spared Muslims during the atrocity - a tactic previously used by al-Qaeda.
Its propaganda agency published photos of the five militants who carried out the atrocity, all dressed in black with Arab-style headscarves, smiling with assault rifles in front of the Isis flag.
Isis gave all the men war names ending “al-Bengali”, indicating that they were from Bangladesh. The eulogies, similar to those following the Paris attacks, suggested the terror group was involved in planning for the attack and training the gunmen.
The claim conflicted with police accounts that at least seven attackers were involved, saying six gunmen had been killed and one captured. The reason for the discrepancy was unclear.
Witnesses described up to nine militants shouting “Allahu Akbar”, meaning “God is great” as they burst into the Holey Artisan Bakery at 9.20pm local time on Friday (4.20pm BST).
Police said that when security forces tried to enter the premises at the beginning of the siege they were met with a hail of bullets and grenades, killing two officers.
Assailants exchanged sporadic gunfire with police outside for several hours as negotiators attempted to contact the militants before troops raided the building, finding the bodies of 20 hostages inside.
A cafe employee who escaped told local television that around 20 customers were in the restaurant at the time, most of them foreigners, and 15 to 20 staff.
The Holey Artisan Bakery, popular with foreign officials and expatriates, sits in the affluent diplomatic quarter of Bangladesh’s capital near the embassies of the US, Turkey, Germany and other nations.
The bodies of nine Italians were identified after the attack, foreign minister Paolo Gentiloni said.
Seven Japanese people, five men and two women who worked as consultants for the country’s international development agency, were also killed.
An Indian teenager was among the hostages murdered, foreign minister Sushma Swaraj said.
She named the victim as Tarushi Jain, 19, and said she had attended the city's American School and studied at Berkeley university in the US.
Two other victims were from at Emory University in Georgia. Abinta Kabir was a student from Miami who had been visiting her family and friends in Bangladesh.
Faraaz Hossain, from Dhaka, graduated from the university’s Oxford College this year and was moving on to its Goizueta Business School.
“The Emory community mourns this tragic and senseless loss of two members of our university family,” a spokesperson said.
The US State Department confirmed that an American citizen had been “senselessly murdered” but did not give any further details.
“This is a despicable act of terrorism, and the United States stands with Bangladesh and the international community in our resolve to confront terrorism wherever it occurs,” spokesperson John Kirby said.
Philip Hammond said the Foreign and Commonwealth Office was investigating whether any British citizens were caught up in the “appalling act of violence” and sent his thoughts to the victims and their families.
The restaurant attack marked a major escalation in two years of increasingly frequent atrocities by Islamist militants in Bangladesh, sparking hundreds of arrests.
A string of machete attacks have been claimed by Isis, al-Qaeda and local groups, targeting secular writers, LGBT activists and religious minorities among others, with the latest victim being a Hindu priest hacked to death at a temple in Jhenaidah on Friday.
Bangladeshi authorities have persistently denied Isis or al-Qaeda have a presence in the country, sparking warnings from counter-terror monitors including the Site Intelligence Group, which urged the government to “face the truth.”
Security officials say two local militant groups, Ansar-al-Islam and Jamaat-ul-Mujahideen, are responsible for the violence.
Isis announced its presence in the country late last year and analysts believe they are recruiting from pre-existing extremist groups who have been carrying out attacks since 2013
Join our commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies