A Bangladesh court has cleared a Canadian university student of all allegations related to a restaurant siege three months ago in which 20 hostages and five attackers were killed.

Metropolitan Magistrate Nur Nabi passed the order Wednesday after an investigator appealed for clearing Tahmid Hasib Khan, an undergraduate student studying global health at the University of Toronto who has Canadian residency.

Prosecutor Abdullah Abu said Khan was cleared of suspicion that he was involved in the attack July 1 on the Holey Artisan Bakery in Dhaka.

He had walked free Sunday after a court granted him bail.

The Islamic State group has claimed responsibility for the attack but the government has blamed local militant groups.

Khan is a permanent resident of Canada and an undergraduate student studying global health at the University of Toronto.

Tahmid Hasib Khan studied at the University of Toronto. (Facebook)

He was released on bail on Sunday after being detained in Bangladesh for three months.

A Canadian lawyer hired by his family said the bail decision on Sunday came after police filed documents with a Bangladesh court saying investigators found no evidence against the 22-year-old in connection with the terror attack.

Khan had arrived in the Bangladeshi capital, Dhaka, on July 1 to celebrate Eid with his family, and planned to travel to Nepal to begin an internship with UNICEF the following week.

He was with friends at the Holey Artisan Bakery when the armed gunmen attacked. Security forces stormed the restaurant on July 2, killing the gunmen and rescuing the remaining hostages.

Khan was held for questioning after the attack and his family said he was detained continuously until his release on bail.

The Toronto lawyer hired by his family said while Khan is now cleared of any involvement in the terror attack, he was facing a "lack of co-operation charge" related to his alleged failure to attend police interviews on July 10 and July 21.

Global Affairs Canada has said it was monitoring Khan's situation and was in touch with his family, his legal counsel and Bangladeshi authorities.