* Government says it's needed to better manage state secrets
* Critics see threat to whistle-blowers and journalists
* Ratings agencies have punished S. Africa for corruption
By Jon Herskovitz
JOHANNESBURG, April 25 (Reuters) - South Africa's parliament approved a bill on Thursday for managing state secrets, ending a three-year battle over legislation critics say could be used to cover up corruption.
The Protection of State Information Bill has been one of the most hotly-contested legislative proposals of President Jacob Zuma's government. The administration says it is needed to provide more effective regulations for managing sensitive information 19 years after the end of apartheid rule.
But critics say the law is open to abuse. They argue it can be used to jail whistle-blowers and journalists who report on a corruption problem that even Zuma's ruling African National Congress (ANC) admits has been eroding confidence in Nelson Mandela's 101-year-old former liberation movement.
The spectre of graft has caught the attention of international investors. Global ratings agency Fitch said rising corruption and deteriorating government performance were among the reasons it downgraded South Africa's credit rating earlier this year.
"What we are seeing is a trend where South Africa's hard-won gains in building an encompassing democracy are slowly being eroded through policy and practice, closing the government off from its people," said Murray Hunter, national spokesman for the Right 2 Know campaign which has opposed the bill.
The group and opposition political parties plan to challenge the law in the Constitutional Court.
The bill spells out a system for classifying information from the military, police and national security agency.
It sets up an oversight body and calls for penalties of up to 25 years in jail for illegal possession and distribution of secrets, while making it a criminal offence to classify a document in an attempt to hide graft.
Under pressure from critics, the secrecy bill has been heavily revised, removing provisions that would have allowed almost any government agency to classify material. The revisions also increased penalties on those who abuse the system and stepped up public interest safeguards.
"We made so many changes that the bill is like a new-born child," Cecil Burgess, an ANC MP, told parliament.
The legislation allows for penalties of five to 25 years in prison if a person possesses and distributes information that could compromise national security.
The secrecy bill was passed in the ANC-dominated parliament with 189 votes for, 74 against and one abstention. It now goes to Zuma, who is almost certain to sign it into law.
WORSENING MARKS FOR CORRUPTION
The law widens the powers of State Security Minister Siyabonga Cwele, a Zuma loyalist, as the gatekeeper of secrets.
Cwele's qualifications have been called into question after his wife was convicted in 2011 for running an international drug ring. The country's intelligence chief said he was unaware of her criminal activity.
South Africa, under ANC rule since the end of white-minority rule in 1994, has slid in the influential Transparency International gauge of perceived corruption from 38th in the world in 2001 when Mandela was president to 69th in 2012.
Zuma, in power since 2009, has said cracking down on corruption is a top priority of his government. Before becoming president, Zuma himself faced graft charges over an arms deal that were later dismissed.
South Africa's Public Protector, a watchdog agency, has been investigating the use of about $23 million in taxpayers' money to upgrade Zuma's private rural homestead. The government has said the money went for necessary security upgrades and there was nothing illegal in the spending.
One of the first tests of the legislation may come regarding a deployment of troops to the Central African Republic, where 13 South African soldiers were killed last month in a shoot-out with rebels.
Zuma and his defence minister have denied allegations the troops were sent to protect ANC business interests in the central African state and said questions about the deployment and demands for more information undermined national security. (Editing by Pascal Fletcher and Andrew Roche)