The government gave no immediate reaction to the judge's ruling, which was delivered in the Pretoria High Court after two South African game breeders fought a legal battle to overturn the moratorium.
The court decision came ahead of a meeting in Johannesburg next year of the Convention on International Trade in Endangered Species of Wild Fauna and Flora (CITES), which could lift the global ban.
South Africa's rhino poaching epidemic saw a record 1,215 rhino killed last year for their horn, and some private rhino breeders say selling legally harvested horns could stifle the lucrative black market trade.
"The moratorium on domestic trade in rhino horns is hereby reviewed and set aside," said the ruling from judge Francis Legodi.
The environment ministry said no decision had been made on whether to appeal.
"Our lawyer is now studying the judgement," ministry spokeswoman Roopa Singh told AFP.
John Hume and Johan Kruger, the two game breeders who launched the legal action, say it is their constitutional right to sell rhino horn -- what they describe as a renewable resource.
"Hopefully this will bring about a change and lead the way to what happens in September next year at CITES," said Izak du Toi, one of Hume's lawyers.
"We believe the South African government is seriously contemplating making a proposal to CITES to allow international trade in rhino horns.
"(Hume) hopes that a legalised trade will lead to a reduction in poaching.
"Lifting of the domestic ban in South Africa is not the entire war won, but it is at least a battle that has been won."
- 'Legal dehorning' -
South Africa is home to around 20,000 rhino, or 80 percent of the world population.
The number of rhino killed rocketed from 13 in 2007 to 1,215 last year.
The animals are slaughtered by poachers for their horn, which is used as a traditional medicine in east Asia.
Legally dehorning a rhino would see a farm owner put the animal under anaesthesia then saw off the horn, which is composed of keratin, the same material as fingernails.
Each horn would require its own permit that would be recorded in a database.
"This step is being considered for financial rather than conservation reasons," said the Save The Rhino group in an email.
The judge said today that the government had not followed correct legal procedures when implementing the ban and had not consulted the public.
"It is maybe on technical point that the judge ruled in the applicants' favour," said leading anti-trade lobbyist Dex Kotze.
"The pro-trade lobby will see it as quite a big win for themselves, but who are they going to sell it to? Because at the end of the day, the South African market doesn't consume."
The decision came after a northern white rhino -- one of just four remaining worldwide -- died Sunday at the San Diego Zoo in the United States.