Johannesburg - Parliament voted on Thursday in favour of a fiercely contested secrecy bill which critics say will muzzle the media and provide cover for government corruption.
The protection of state information bill, which will replace apartheid-era legislation on classified information and espionage, passed with 189 votes in favour to 74 against, with one abstention.
The minister of state security, Siyabonga Cwele, told Parliament the bill would "strengthen democracy while balancing transparency and protecting our national security and national interests".
"There is no one who can hide corruption through this act," he said, adding that the revised bill provided whistleblowers even more protection.
Under the bill, espionage-related cases carry a punishment of up to 25 years in jail, and holding or disclosing classified material carries a maximum of five years' imprisonment.
The bill has met fierce opposition from the media, rights groups and the opposition, which fear it will be used to persecute whistleblowers and stifle press freedom in country where the media regularly uncover government corruption and wasteful spending.
In recent years journalists have used leaked documents to level accusations of high-level corruption against leading members of the ruling African National Congress.
They included President Jacob Zuma, who was implicated and appeared in court on charges relating to the arms deal. The charges were dropped just months before he became head of state.
Media reporting has also led to allegations that Zuma spent millions of rands to renovate his private home.
Since first mooted in 2008, the bill has undergone several amendments, but was ultimately pushed through by the ANC's overwhelming parliamentary majority.
Opposition Democratic Alliance (DA) parliamentary leader Lindiwe Mazibuko slammed the bill as a "unconstitutional" and a threat to "democracy's foundational values of freedom and openness".
"Media cannot function when important information is suppressed. Bad governance thrives under the cloak of darkness. Those who have nothing to hide have nothing to fear," she said.
The DA said it would lobby other opposition parties to challenge the bill in the Constitutional Court.
The bill is now expected to be signed into law by Zuma.