The highest court in South Africa has legalized cannabis in a landmark ruling that sparked scenes of joy across the country.

“It will not be a criminal offence for an adult person to use or be in possession of cannabis in private for his or her personal use.”

The Constitutional Court, equivalent to the US Supreme Court, upheld a lower court’s ruling that the criminalization of cannabis was unconstitutional. It is now no longer a criminal offence to grow cannabis and use it at home, although smoking it in a public place is still outlawed, as is supplying it.

Several factions within the South African government, including the departments for health and justice, had been lobbying against decriminalization. But the Constitutional Court made a unanimous judgment and deputy chief justice Raymond Zondo said: “It will not be a criminal offence for an adult person to use or be in possession of cannabis in private for his or her personal use.”

South African parliament now has two years in which to change the law, but in the meantime cannabis users will be protected by the judgment. It will also be down to parliament to decide the amount of cannabis that an individual can possess or cultivate at any one time.

Because supply remains outlawed, the South African government cannot turn a profit by taxing a regulated industry. That could come soon, as South Africa is a major exporter of cannabis to the UK and continental Europe, so the government may decide to cash it. But it spells the end of an era that has seen many South Africans jailed on a regular basis for possessing small amounts of cannabis. It follows moves in Zimbabwe and Lesotho to permit medical use of marijuana.

Activists in South Africa – where cannabis is known as “dagga” – are delighted with the ruling, which was a result of intense campaigning from Rastafarian Gareth Prince, former Dagga Party leader Jeremy Acton and so-called “dagga couple” Jules Stobbs and Myrtle Clark. They had argued that the cannabis ban defied the constitution as it violated an individual’s right to equality, dignity, privacy and freedom of religion. A ban on cannabis, said Stobbs and Clark, “intrudes unjustifiably into their personal spheres” after they were charged for using cannabis.

The Constitutional Court withstood pressure from the government and the police force to strike down the lower court’s judgement. Police argued it would embolden gangs, whereas the government said it is harmful to people’s health. But section 14 of the country’s constitution gives all citizens the right to privacy, and the court found a ban on personal use to violate that.