Image copyright Getty Images Image caption Twenty hostages, mostly foreign, and two police officers died in the attack

A Canadian student and a British man have been arrested for their alleged roles in an attack on a cafe in Bangladesh in which 22 people died.

University of Toronto student Tahmid Hasib Khan and British national Hasnat Karim were taken into custody in Dhaka.

Gunmen attacked the Holey Artisan cafe in the Bangladeshi capital on 1 July, killing customers and taking hostages, before troops entered 12 hours later.

The pair arrested had not been heard from since the attack.

Nine Italian nationals, seven Japanese, one American and an Indian were killed during the siege by Islamist militants.

Two Bangladeshis died, in addition to two police officers and at least five of the attackers.

Officials said the attackers belonged to banned domestic group Jumatul Mujahedeen Bangladesh (JMB), although so-called Islamic State said it carried out the attack.

They said the victims had been attacked with sharp weapons.

Mr Khan, 22, and Mr Karim, 47, were among 13 people, presumed to be hostages, who came out just before security forces stormed the cafe.

The pair were taken into custody on Thursday and police would have eight days to question them, a police spokesman, Masudur Rahman, said.

The men's relatives have previously accused police of holding the men secretly since the attack, although police deny doing so.

Mr Karim's lawyer, Rodney Dixon, filed a complaint with the UN human rights council seeking Mr Karim's immediate release.

"They have had more than sufficient time to make any inquiries. There is clearly no evidence to charge him and he should be let go without any further delay," Mr Dixon told Reuters.

The family of Mr Khan, who is of Bangladeshi origin and a permanent resident in Canada, appealed for help last month to Canadian Prime Minister Justin Trudeau.

Foreign Affairs Minister Stephane Dion had said government officials were in contact with Bangladesh officials and were monitoring the situation.

Human rights groups have criticised Bangladeshi police for holding the men and allegedly denying them access to lawyers.

Mr Khan, an undergraduate student studying global health, was visiting family in Dhaka and was expected to begin an internship in Nepal last month.

Media playback is unsupported on your device Media caption What we know about the attackers of the Dhaka cafe

Mr Karim, who also has Bangladeshi citizenship, was at the restaurant with his wife and two daughters when the attack occurred.

The authorities said they had obtained photographs allegedly showing Mr Karim smoking on the rooftop with two of the attackers standing behind him.

Police also said footage shot from a nearby flat purported to show Mr Karim talking to the attackers.

Mr Karim returned to Bangladesh a few years ago after living in the UK for nearly 20 years.

He briefly taught at a private university in Dhaka before going into business in 2012.