The court rejected the request that the camps be kept open until their occupants can be properly reintegrated into the communities from which they were driven.
The application was brought by the Consortium for Refugees and Migrants in South Africa and the law clinic of the University of Witwatersrand, which argued that the government has failed to offer a reintegration plan and therefore has not respected the rights of the displaced.
About 4,000 displaced people are living in the camps – most of them Zimbabweans.
Advocate Jacob Van Garderien, director of the South African Lawyers for Human Rights and a member of the Consortium for Refugees and Migrants, told reporter Sithandekile Mhlanga that his group is disappointed with the ruling by the Pretoria court and will appeal it.