India's Supreme Court has ordered the country's overcrowded jails to free all inmates who have served half their maximum possible term without trial, in a landmark ruling with potential implications for hundreds of thousands of prisoners.
More than two-thirds of the country's nearly four million prison inmates are awaiting trial, according to Amnesty International, many having already spent years in prison.
Indian law already states that prisoners awaiting trial must be released once they have served half the maximum sentence they would receive if found guilty, but the law is rarely implemented.
On Friday, Chief Justice RM Lodha said prisons across the country must comply with the law, and ordered local judges and magistrates to oversee the process.
"Judicial officers shall identify prisoners who have completed half of the maximum period of imprisonment provided for offences they are charged with," he said.
"After completing the procedure they should pass appropriate orders in the jail itself for the release of undertrial prisoners."
It is not yet clear exactly how many prisoners will be affected by the ruling.
Last month, G Ananthapadmanabhan, the chief executive of Amnesty International India, said that "thousands of poor and voiceless undertrial prisoners, by the government's own admission, are locked away for long periods in prison, awaiting trial for minor offences".
Suhas Chakma, director of the New Delhi-based Asian Centre for Human Rights, welcomed Friday's ruling.
"Most of the time those languishing in jails are poor and illiterate people who are not aware of their rights," he said.
"In fact, the government should also pay compensation to such people for making them suffer in jails."
Rights activists say India's justice system is slow, inefficient and sometimes corrupt, meaning inmates can wait years to have their cases heard in court.
Official figures show there were more than 30 million trials pending across India at the end of 2012.