The tussle over the painting is the latest battle over free speech in a country where the government has taken increasingly firm steps to squelch critics despite one of the world’s most expansive sets of individual rights, enshrined in its 15-year-old Constitution.

At the center of the controversy is a six-foot-tall acrylic on canvas, called “The Spear,” painted by Brett Murray, an artist based in Cape Town. It is part of an exhibition of his work at the Goodman Gallery called “Hail to the Thief II.”

The painting depicts a man who resembles Mr. Zuma in a heroic, Leninesque pose, but his genitals appear to be hanging out of his trousers. Mr. Zuma, a practicing polygamist who has 4 wives and at least 20 children, had been charged with rape before he became president.

In 2006, he was acquitted of raping the daughter of a friend; he said the sex was consensual. He was heavily criticized for his testimony at the trial, in which he argued that the woman had dressed provocatively and that as a Zulu man, he was required to sexually gratify her.

The woman was H.I.V. positive, and Mr. Zuma did not use a condom; he testified that he showered immediately afterward in the hope of avoiding infection, a response that shocked many people in a country grappling with some of the highest rates of H.I.V. infection in the world.

Mr. Murray’s artworks, done in the style of Soviet propaganda, tackle government corruption, an issue that fills newspapers in South Africa every day and has become a major source of disillusionment among citizens of this young democracy.

One canvas features the logo of the African National Congress, the liberation movement that ended apartheid and now governs South Africa, with the words “for sale”; another with the logo includes the word “sold.” One poster uses a popular slogan of the struggle against apartheid, “amandla,” or “power,” to show protesters demanding not freedom but “Chivas, BMWs and bribes.”

In a statement, the A.N.C. called “The Spear” “distasteful, vulgar, indecent and disrespectful,” and “an affront to the dignity and the privacy of President Zuma in all his capacities, but also as a South African whose right to human dignity and privacy is protected and guaranteed by the South African Constitution.”

The Goodman Gallery responded by arguing that the artist had a right to express his views through his paintings.

“The gallery provides a neutral space in which dialogue and free expression is encouraged,” it said in a statement. “In this space, the A.N.C.’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.”

Mr. Murray has declined to talk about the dispute; through the Goodman Gallery, he has said he prefers to let the art speak for itself. But other South African artists have quickly risen to his defense. William Kentridge, perhaps South Africa’s most famous visual artist, said in an affidavit in support of the Goodman Gallery, “Both the work of the artist and the controversy his work arouses are to be welcomed,” and South Africans are “fortunate to live in a country with a Constitution that acknowledges the importance of open debate on all issues.”

Vandals splashed paint on the painting on Tuesday, painting an X over the subject’s face and black paint on the genitals. The Goodman Gallery said it was forced to close the exhibition temporarily.

The painting has stirred passionate debate about the limits of free speech and racism in a society still emerging from decades of white-minority rule.

Gwede Mantashe, a senior leader of the A.N.C., said the painting played into stereotypes of black men as hypersexualized.

“It is rude, crude and disrespectful,” he told reporters in Johannesburg. “It has an element of racism. It says that black people feel no pain and can be portrayed walking around with their genitals in the open. They are objects of ridicule. I can tell you that if you were to draw a white politician in that way, the outcry would be totally different.”

But Mondli Makhanya, a senior columnist at The Sunday Times, a South African newspaper, wrote that Mr. Zuma’s outsize sex life made the topic fair game.

“It will be his sexual legacy that we will remember more than anything else,” Mr. Makhanya wrote of Mr. Zuma. “His sexual endeavors are therefore fair game for artists, cartoonists, comedians, radio D.J.’s and tavern jokers.”