Dr Kafeel Khan told Al Jazeera he was physically tortured while in captivity, which included him being stripped of his clothes and beaten and deprived of food for days.
"It was very hard for the whole family. My 65-year-old mother was forced to visit the courts during the peak of the coronavirus pandemic," he said.
Dr Khan was arrested in January for a speech made a month earlier that authorities in Uttar Pradesh (UP), governed by Prime Minister Narendra Modi's Bharatiya Janata Party (BJP), deemed incendiary. He was later charged under the National Security Act (NSA), which stipulates that a person can be held without charge for a year.
His speech focused on major issues facing the country of 1.4 billion people such as malnutrition, lack of health facilities and unemployment crisis.
They really wanted to break me this time.
But Khan's criticism of the Citizenship Amendment Act (CAA), which bans Muslims from neighbouring South Asian countries from gaining Indian nationality, seemed to have earned him the government's ire.
The passing of the law in December sparked nationwide protests led mostly by Muslims - India’s largest minority, numbering nearly 200 million.
Yogi Adityanath, who is UP's chief minister and known for his anti-Muslim statements, ordered a crackdown against anti-CAA protests in the northern state. More than two dozens Muslims were killed in police action that was condemned by Amnesty International India.
"Who will speak up in this time of atrocities, if we are also quiet, who will raise their voice?" Khan had said during the speech in front of students of Aligarh Muslim University, located around 125km from the capital, New Delhi.
Critics and family members say the 38-year-old paediatrician was targeted because he chose to speak up against the law, which the United Nations dubbed "fundamentally discriminatory".
The UP police department in its complaint accused Dr Khan of "sowing seeds of discord towards other religious communities".
But the Allahabad High Court on Tuesday disagreed with the police, saying "a complete reading of the speech also nowhere threatens peace and tranquility of the city of Aligarh [located in UP]".
Dr Khan is rising as a prominent Muslim face in India, which the government doesn't want ... they don't want an educated Muslim person raising his voice, about their rights or equality.
"The address gives a call for national integrity and unity among the citizens. The speech also deprecates any kind of violence," the 42-page judgement read as it ordered the immediate release of Khan.
Dr Khan said that after he was slapped with the NSA, his family became "untouchable" as people avoided contact with them in their home city of Gorakhpur in UP. "Lawyers would not take my case," he said.
His activism has also brought troubles to his family. His brother Adeel Khan said his business has been targeted since Kafeel Khan was arrested in 2017. Another brother survived a gun attack.
The 38-year-old doctor's release on Tuesday ends his third stint in prison [Courtesy family of Dr Kafeel Khan]
Harjit Singh Bhatti, a doctor based in New Delhi, has been one of Khan's most vocal supporters. He said that Khan has been presumably targeted because of his religion.
"Dr Khan is rising as a prominent Muslim face in India, which the government doesn't want ... they don't want an educated Muslim person raising his voice, about their rights or equality," Bhatti told Al Jazeera.
Dr Khan has spent nearly 500 days in prison in the last three years, as his case has become a symbol of state repression on dissent.
And he is not the only one. Several activists behind the peaceful anti-CAA protests are still behind bars for opposing the government's alleged anti-minority policies.
The address gives a call for national integrity and unity among the citizens.
Rights groups have condemned their continued incarceration as the coronavirus virus pandemic poses a threat to their life in India's crowded prisons. On Monday, India overtook Brazil to become the second-worst country hit by COVID-19 with over 4.2 million cases.
The 38-year-old doctor's release on Tuesday ends his third stint in prison.
His ordeal with the BJP-led UP government began in September 2017, when he was arrested in the wake of the deaths of 70 children due to lack of oxygen supply at Baba Raghav Das (BRD) Medical College hospital in Gorakhpur, Khan's hometown.
Then a junior doctor in the paediatrics department, Dr Khan was hailed as a hero for securing a supply of oxygen tanks for the hospital ward from his personal money.
However, according to Dr Khan, the incident did not go down well, with Adityanath chastising Khan for his efforts upon meeting him days after the incident.
Khan was arrested with eight others for the deaths of the minors, and jailed for seven months.
He was arrested again a year later for 45 days, after authorities claimed he had barged into a hospital in the Bahraich district in UP, leading to an alleged ruckus.
The doctor claims he went to the hospital to enquire about the deaths of children at the hospital from encephalitis, an inflammation of the brain. Thousands of children have died in Uttar Pradesh and in neighbouring Bihar state due to episodic outbreaks of encephalitis since the 1970s.
In 2018, an investigating team looking into the BRD hospital tragedy exonerated the paediatrician of any criminal wrongdoing. Khan has sought an apology from the Adityanath-led government and the reinstatement of his job.
But instead, the government ordered another inquiry into the children's death case.
Dr Bhatti, who is also the President of Progressive Medicos and Scientists Forum, said Khan has been made a "scapegoat".
"Khan has been continuously made a scapegoat for the BRD tragedy, despite being a junior doctor at the hospital," Bhatti told Al Jazeera.
Bhatti has been an outspoken critic of the Modi government's coronavirus pandemic policy, as the country has emerged as the epicentre of the virus in Asia.
Khan, who has moved to western Rajasthan state since his release, says he feared for his life inside the jail. "For the first four to five days of my incarceration, I did not receive any food. I wore the same clothes ... I was not able to take a bath or brush my teeth."
"To go to the toilet there was a queue of 30 minutes," he said, adding that he had to share the barrack with some 150 people while it actually had the capacity to hold 40.
"They really wanted to break me this time," he told Al Jazeera.
The paediatrician said at times he would bite on his sleeves to distract himself from the excruciating hunger he experienced. "I was in so much pain I could have eaten grass," he said.
He said that jail authorities asked him to stop talking about the BRD hospital tragedy, and also demanded that he stop criticising CAA and a proposed citizenship register, which critics fear will likely be used to disenfranchise Muslims.
Despite the immense hardships, Khan revealed that his fellow prisoners, who were aware of his heroics during the BRD episode, would help him with food and other requests during his incarceration.
Khan has temporarily moved to Jaipur, the capital of Rajasthan state, where he has been reunited with his family, including his two children, wife and brother.
He said his most pressing concern is to demand the UP government revoke his suspension from his previous post at the BRD hospital so that he could resume his work.
"For the past three years," he said, "I have written 25 letters to the UP government to either revoke my suspension or terminate me, so that I can go work somewhere else."