Judge Collin Lamont went further than AfriForum, the white rights group that brought the hate-speech lawsuit, had demanded by saying that all South Africans, not only Julius Malema, should refrain from singing "Shoot the Boer." Under the ruling, criminal cases can now be brought against those who sing the song or quote its lyrics.
In a ruling broadcast live on national television, the judge said that while such anthems had their place during apartheid, they constitute hate speech in a society now struggling to redefine relations between the races.
The court case is separate from Malema's ongoing African National Congress disciplinary hearings, which also have drawn wide attention.
While Monday's judgment could be seen as a setback for the embattled Malema, the lightning-rod figure might use it to rally support from South Africans who see "Shoot the Boer" as part of the heritage of the anti-apartheid movement. "Boer" means farmer in the language of South Africa's Dutch descendants known as Afrikaners, and is broadly used to refer to whites in general and Afrikaners in particular.
In a statement, the ANC said it was "appalled" by the decision, but would respect it while deciding what steps to take next.
Malema, who was not in court Monday but testified at length during hearings earlier this year, had argued the song was not a literal threat against whites. Malema and the ANC said it was a symbolic call to fight oppression, both under apartheid and 17 years after the end of white rule in a society where the black majority largely remains poor.
After the ruling, crowds outside the downtown Johannesburg courtroom sang the song in defiance of the judge. ANC Youth League leaders urged them to respect the ruling while they consulted with their lawyers about whether to appeal or take other steps.
Malema, 30, has forced South Africa to confront its racial divide, insisted on trying to set his party's political and economic agenda, and claimed to represent the country's restive, poor, black majority. The disciplinary hearings, which could lead to Malema's suspension or expulsion from the party, focus on accusations he is undermining President Jacob Zuma.
The ANC leaders who make government policy have consistently — and at times mockingly — rejected Malema's calls to nationalize mining or confiscate property from whites to hand over to blacks. But he cannot be ignored. The vehemence and volume of his rhetoric could, over time, be influential.
And his Youth League's reputation for getting voters to the polls means it has influence when the party draws up candidate lists. Malema took credit for putting Zuma at the top of the ANC list in 2009, though he now accuses the president of being too moderate. The next election is in 2014, but the ANC could replace Zuma before that in a process akin to a vote of confidence within the party.
Malema was raised by a single mother who worked as a maid in one of South Africa's most impoverished regions. He shares those biographical details with Zuma, and they explain some of his appeal among poorer South Africans.
His appeal has not been undermined by his recent acquisitions of expensive cars, flamboyant friends and a home in one of Johannesburg's most expensive neighbourhoods. Critics question whether he's sold political favours to get his wealth, charges he denies even as police and an anti-corruption office investigate. Critics also say he sets an example that feeds materialistic aspirations among young South Africans that their elders fear have crowded out the previous generation's goals of replacing apartheid with a just and humane society.
In the hate speech case, AfriForum chief executive Kallie Kriel said at court Monday his group respected the heritage of the anti-apartheid movement, but agreed with Lamont that South Africa now should move on.
"We need to find mutual recognition and respect among communities," he said, calling the ruling a victory over Malema's vision of South Africa.
Leslie Mkhabela, Malema's lawyer, said he did not believe courts were the right forum to debate such social issues.
The judge had made a point similar to Mkhabela's during the trial, urging the parties to find a mediated settlement. Monday, he said he hoped the attention the trial had drawn, and his decision to allow much of it to be broadcast, would help South Africans heal by learning about each other after decades of being separated by the violence and injustice of apartheid.
Lamont spoke for nearly two hours before delivering his ruling, touching on South Africa's colonial history, the struggle against apartheid and the media attention and public outrage Malema had drawn with his insistence on singing such lyrics as "shoot the boer, they are rapists, robbers."
Lamont also spoke of the limitations of the law, acknowledging that while he could issue an order banning a song, many South Africans "are passionate about the right to sing the song."
He urged South Africans to "pursue new ideals and find a new morality. They must develop new customs and rejoice in developing society by giving up old practices which are hurtful to members who live in that society with them."