The Isis fighters who massacred at least 22 people at a café in Bangladesh ordered hostages to recite verses from the Quran and “tortured” anyone who could not, it has emerged.

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.

Twenty hostages killed in Bangladesh cafe attack

“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.

Security personnel keep watch, after gunmen stormed the Holey Artisan restaurant and took hostages, in the Gulshan area of Dhaka, Bangladesh July 2, 2016. (Reuters)

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.

People help an injured person after a group of gunmen attacked a restaurant popular with foreigners in Dhaka, Bangladesh (AP)

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.

In pictures: Bangladesh attacks Show all 10 1 /10 In pictures: Bangladesh attacks In pictures: Bangladesh attacks Bangladesh attacks Hindu ashram worker Nityaranjan Pande, 62, was hacked to death in Pabna on 10 June 2016 AP In pictures: Bangladesh attacks Bangladesh attacks Hindu priest Anando Gopal Ganguly, left, was murdered in Jhenidah in Bangladesh on 7 June 2016 EPA In pictures: Bangladesh attacks Bangladesh attacks Mahmuda Khanam Mitu, wife of the Deputy Commissioner of Chittagong Metropolitan Police, was murdered in Chittagong, Bangladesh on 5 June 2016 EPA In pictures: Bangladesh attacks Bangladesh attacks Bangladesh Students Union arranged a torch procession in protest over recent murders of free thinkers in Dhaka NurPhoto In pictures: Bangladesh attacks Bangladesh attacks Murdered gay rights activist Xulhaz Mannan, who was editor at Bangladesh’s only LGBT magazine Rex In pictures: Bangladesh attacks Bangladesh attacks A Bangladeshi policeman stands guard at the site of the murder of a law student, hacked to death by four assailants the night before, in Dhaka on April 7, 2016 AFP/Getty In pictures: Bangladesh attacks Bangladesh attacks People have protested against the murders around the world, seen here in Kolkata AFP/Getty Images In pictures: Bangladesh attacks Bangladesh attacks A relative of dead Bangladeshi blogger Washiqur Rahman reacts after seeing his body at Dhaka Medical College in Dhaka on March 30 AFP/Getty Images In pictures: Bangladesh attacks Bangladesh attacks People gather on the spot where Bangladeshi blogger Avijit Roy was killed in a street in Dhaka (EPA) EPA In pictures: Bangladesh attacks Bangladesh attacks Bangladeshi social activists shout slogans during a protest against the killing Avijit Roy in Dhaka on February 27, 2015 AFP/Getty Images

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.