He spent some time in New Delhi's Tihar jail where he came into contact with terrorists Omar Sheikh and Masood Azhar.
Kiran Bedi was then in charge of Tihar and trying to reform the jail system. Azmi, who had passed his Class Ten examination, took advantage of Bedi's reforms and became a lawyer while serving out his sentence.
'Why the educated Muslim is taking to violence'
Twenty-eight men have been named in the chargesheet filed in the Mumbai blasts case, of whom 13 have been arrested. The case, which commenced in Mumbai last August, has since run into a legal roadblock erected by Azmi.
Azmi contended that the law under which the accused are being tried -- the Maharashtra Control of Organised Crime Act -- was itself illegal. The Supreme Court stayed the proceedings in the case till it studied the merits of his arguments.
"Firstly, the accused are not perpetrators of the blasts," Azmi told rediff.com "Each one has been arrested for a different reason. Two brothers, Muzzamil Sheikh and Faisal Sheikh, were accused of arranging arms."
Another was an accused in the Aurangabad arms haul case, Azmi says, and was first declared 'wanted' in that case. The Mumbai blasts occurred between the date of his being declared a wanted criminal and the day he was actually arrested.
"He was arrested on July 23, 2006. The police did not claim any arrest in the July 11 case till September 30. So it took the police more than two months to decide that he was involved in the blasts," Azmi said.
Naveed Hussain was arrested because he is a friend of the two brothers, Azmi alleged, and Zameer Sheikh was arrested for having connections with the outlawed Students Islamic Movement of India.
Majid Mohammad Shafi was arrested because he has relatives who help people cross the border between India and Bangladesh. "It does not mean they know what the people do after they cross the border," Azmi claims.
He alleges that the police "arrests anyone and everyone to keep the media pressure off."
Every act of terror is an opportunity for the police to arrest people they suspect of helping the perpetrators, says Azmi. They have a name for such individuals, he adds -- 'sleeper cells'.
"We are challenging the very Act under which they (the July 11 accused) are being tried. A state government does not have the power to frame a law against terrorists and anti-insurgency. Only the central government can do that."
Secondly, he says, after the Maharashtra government framed the MCOCA, the central government created another law to curb terrorism. "That law will make this state law irrelevant and also overrule it," he says.
"Once the law goes, the confessions obtained under it will also be rejected. My clients will then have to be released because there is no evidence against them," he says.
Photograph: Rajesh Karkera