It began with an impression of a man's penis in an art gallery where only a tiny fraction of the population would normally set foot. Now it has become a national debate running the gamut from freedom of expression to the right to privacy, from the nature of racism to "what is art?", and is being seen as nothing less than a test of South Africa's constitutional democracy.

On Wednesday the president, Jacob Zuma, will bring a court action to argue that a painting showing him with exposed genitalia should be removed because it violates his right to dignity and makes a mockery of his office.

The claim is disputed by the Goodman Gallery in Johannesburg, which is displaying the 1.85m-high (6ft 1in) painting, entitled The Spear, as part of artist Brett Murray's Hail to the Thief II exhibition.

Freedom of speech is protected in South Africa but Zuma's governing African National Congress (ANC) believes that, in this instance, it has a case beyond mere censorship of its critics. It contends that the artwork is playing up to crude stereotypes of African male sexuality. It is no doubt aware that Murray is white.

Zuma states in a legal affidavit: "The continued display of the portrait is manifestly serious and has the effect of impugning my dignity in the eyes of all who see it. In particular, the portrait depicts me in a manner that suggests that I am a philanderer, a womaniser and one with no respect. It is an undignified depiction of my personality and seeks to create doubt about my personality in the eyes of my fellow citizens, family and children.

"In terms of the theme of the exhibition, my portrait is meant to convey a message that I am an abuser of power, corrupt and suffer political ineptness."

The president added that he was shocked and "felt personally offended and violated".

The ANC has been rallying around its leader over the painting. Gwede Mantashe, its secretary general, said on Monday: "It's rude, it's crude, it's disrespectful."

If it had been a white man depicted, the reaction would have been very different, he added, but as far as many people were concerned, black people were just objects.

"I said, 'How about the idea of going to court tomorrow and as we sit there we can take off our trousers? ... we can walk around with our genitals hanging out'.

"It's crude … we have not outgrown racism in our 18 years [of democracy]."

Ngoako Selamolela, president of the South African Students' Congress, added: "This arrogance is ideological and an attack to the very value and moral systems of the majority African people and many other religious persuasions."

And Wally Serote, a leading poet and writer, suggested the painting was no different to labelling black people "kaffirs" – a highly offensive term.

"Blacks feel humiliated and spat on by their white counterparts in situations like this," he was quoted as saying. "We all need to learn that as creative people we have a responsibility to see that our work contributes to building a new South Africa, free from prejudice."

Other South Africans, both black and white, have taken the view that, as a public figure, Zuma should be thick-skinned when it comes to satire.

Tselane Tambo, daughter of the late ANC stalwart Oliver Tambo, reportedly posted on a social networking site: "So the Pres JZ has had his portrait painted and he doesn't like it.

"Do the poor enjoy poverty? Do the unemployed enjoy hopelessness? Do those who can't get housing enjoy homelessness? He must get over it. No one is having a good time. He should inspire the reverence he craves. This portrait is what he inspired. Shame neh!"

The row has been good for business at the gallery, where staff estimate there were 50 or 60 visitors at any one time on Saturday, more than double the usual attendance.

A spokeswoman for the gallery said: "The gallery provides a neutral space in which 'dialogue and free expression' is encouraged. In this space the ANC's right to condemn the work is acknowledged as much as the artist's right to display it. This, the gallery believes, is democracy at work.

"But the gallery cannot give up its right to decide what art will hang on its walls. For this reason we are opposing the application brought by the ANC and President Zuma for the removal of the artwork."

The Goodman Gallery will be increasing security and may search visitors, she added, amid rumours of a possible public protest. South Africa's Sunday Times reported that The Spear had been sold for 136,000 rand (£10,345) to a German buyer.