Sri Lanka's supreme court announced on Friday that it would hear a petition submitted by Fonseka's wife calling for his arrest to be ruled illegal, and ordered the state to allow him family visits and medicines.
'Breach of rights'
"The court granted leave to proceed with the case because it appeared, on the face of it, there had been a breach of fundamental rights of General Fonseka," a court official told AFP news agency.
The court was scheduled to reconvene on February 23 for a further hearing.
The government has yet to specify the charges Fonseka will face, but Gotabhaya Rajapaksa, the defence secretary and the president's brother, said he had clearly been plotting a military coup.
Fonseka's detention has sparked international concern with the US, the EU and the UN, among others, asking Colombo to ensure that due process was followed and that democracy was not undermined.
It has also led to violent protests in Colombo between pro and anti-government demonstrators.
Fonseka was hailed a national hero for leading the army that finally crushed the separatist Tamil Tigers last May, ending their 37-year campaign for an independent Tamil homeland.
Fonseka, who quit the military in November, used his fame to enter politics as an opposition presidential candidate.
He was arrested on February 8, two weeks after being defeated in the elections by a solid margin by Rajapaksa.