More than two-thirds of India'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 that law is rarely implemented.
On Friday the country's 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 under trial prisoners."
It is not yet clear how many prisoners will be affected by the ruling.
But G Ananthapadmanabhan, chief executive of Amnesty International India, said last month that "thousands of poor and voiceless under trial 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.
Earlier this year the Supreme Court ruled that "inordinate and inexplicable" delays in carrying out an execution were grounds for commuting a sentence.
COMMENTS (2)
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ
@WB: Had your word been true, people would have been cutting each other's throat in India. The situation is not as bad as you potray. Look at recent spate of cases. Governments got crushed who showed apathy towards general public. Calling everyone corrupt, show one's state of mind.
This is the sorry state of Indian judicial system.
The claim of a free country is so vacuous that it shames us.
Police is utterly incompetent and corrupt. Judiciary is incompetent, corrupt and overburdened.
The rich and the powerful of the country rule.
Ordinary citizens getting justice in India is very unlikely.
India is not a modern secular democracy. India is a modern slave state, a failed state, a modern zameendar state, an elitist corrupt cesspool.
And only fools keep hoping for ache din, even the blame should be taken by each and every Indian who is corrupt in one or another way.
This order is good for innocents who are languishing and horrible for criminals who are also languishing.
I doubt if Mughal rule was worse than independent India.