But he added in an hour-long Easter interview with the SABC that the government had failed to engage adequately with the companies that own the patents on key drugs to negotiate affordable prices.
"I think the pharmaceuticals are exploiting the situation that exists in countries like South Africa - in the developing world - because they charge exorbitant prices which are beyond the capacity of the ordinary HIV-Aids person. That is completely wrong and must be condemned.
"The government is perfectly entitled, in facing that situation, to resort to generic drugs and it is a gross error for the companies, for the pharmaceuticals, to take the government to court," the 82-year-old Nobel Peace laureate said.
The case brought by the drug companies against the government is due to resume in Pretoria on Wednesday.
The companies and the Pharmaceutical Manufacturers' Association of South Africa are trying to block a new law, which it argues infringes their patent rights and could undermine the funding of future research.
Pretoria, supported by Aids groups, contends the Medicines and Related Substances Control Amendment Act is vital to meet its constitutional duty to deliver affordable and sustainable health care to millions denied care during apartheid.
The law would allow South Africa to circumvent patents and to import or to manufacture copies of modern Aids drugs.
Government figures show that one in nine South Africans is infected with HIV or already has Aids and only a tiny minority of those 4.7 million people can afford appropriate drugs.
Mandela said the government's priority had to be the provision of affordable medicines. South Africa has the highest number of HIV/Aids sufferers in a single country.
öNot enough done to persuade pharmaceuticalsö
"Having said that, I want also to say that we must also take responsibility for not doing sufficient work to persuade these pharmaceuticals to change their approach," he said.
Mandela has been cautious since he retired in 1999 as South Africa's first democratically elected president to avoid overt criticism of his successor, Thabo Mbeki.
Mbeki has stirred controversy, however, by citing personal Internet research and the views of dissident scientists to question the link between the Human Immunodeficiency Virus (HIV) and the Acquired Immune Deficiency Syndrome (Aids).
His government has refused antiretroviral drugs to most people living with HIV and AIDS, including pregnant women.
Several pharmaceutical companies allege that Mbeki's government has ignored repeated offers of gifts and price cuts.
In an apparent message to Mbeki and to Health Minister Manto Tshabalala-Msimang, Mandela said: "There is nothing as important as dialogue in trying to resolve problems.
"If we have a clear and connected plan to persuade the pharmaceuticals to settle and to charge prices which are affordable to the masses of the people, I am sure that the result would be positive," he said.