Almost 400 men, women and children from the minority Tamil community were expelled from the capital Colombo by armed police and security forces and left stranded in the northern town of Vavuniya on 7 June.
They were herded into buses in a dawn raid by police and army personnel from guest houses in Colombo and dropped hundreds of kilometres from their homes in war-torn northern and eastern areas, some of which are very isolated.
The Supreme Court made the ruling after a local activist organisation, the Centre for Policy Alternatives, petitioned against the expulsion order.
The US government joined several human rights organisations here and abroad to condemn the expulsion and call for a stop to the alleged discrimination.
"The United States condemns the forced removal of Tamils from Colombo," a statement released by the embassy said. "We call upon the government of Sri Lanka to stop the forcible removal of its citizens from Colombo, make public the destinations of those already removed, and ensure their safety and well-being."
Human Rights Watch said the move was "blatantly discriminatory" and would fuel ethnic conflict.
At least eight bus-loads of Tamils originally from Jaffna District and eastern Trincomalee were forced to occupy a school in Vavuniya in the security operation aimed at ridding Colombo of suspected Tamil Tiger separatists.
Meanwhile, non-governmental organisations helped the evictees in Vavuniya. "We have been providing food and water since last evening and right now, we are assessing the situation there," Davide Vignati, communication coordinator for the International Committee of the Red Cross told IRIN.
Government defence spokesman Keheliya Rambukwelle described the operation as helping the "voluntary return" of the Tamils, but evictees and guest-house owners told how old and young were woken up and ordered to board buses without carrying any food, clothes or money.
"We were not allowed to change our clothes or even use the toilet," one of the expelled Tamils told a television station.
Colombo has a large Tamil community but many Tamils come to the capital to get medical treatment, visas to go abroad or to transact other business. They typically stay in lodges offering cheap accommodation. Since fighting between government troops and the separatist Liberation Tigers of Tamil Eelam (LTTE) intensified last year, Tamils from the embattled north and east are required to have a special pass to travel anywhere else in the island.
The 7 June operation came a week after Inspector General of Police Victor Perera said Tamils who were "loitering" in Colombo would be given transport to return home unless they had proof of employment there.
The Defence Ministry said the move was necessary to secure the capital against bomb attacks carried out by Tamil Tigers which claimed the lives of nine people last month. "Investigations have also confirmed that those responsible for these brutal killings have hatched their brutal plans and executed them from these 'lodgings'," the ministry said.