A controversial law to protect state secrets has been approved by South Africa's parliament, despite objections from Archbishop Desmond Tutu, rights organisations, and a group representing Nelson Mandela.

The African National Congress majority ensured that 229 MPs voted in favour of the protection of state information bill, with 107 votes against and two abstentions.

The ANC claimed it was updating legislation drawn up 30 years ago by the apartheid government.

Llewellyn Landers, an ANC MP, said the bill would not have a public-interest defence clause because "it would do irrevocable harm to the state and the people of South Africa if a court should find that a whistleblower was found to have given information not out of public interest but out of maliciousness".

But rival MPs united against the "secrecy bill", legislation that critics argue is the first piece of law-making since the end of apartheid to dismantle a part of South African democracy.

The law would make it a crime to leak, possess or publish information judged as classified by the government. Whistleblowers and journalists could face up to 25 years in jail if found guilty of such action.

In a rousing speech from the floor on Tuesday, Lindiwe Mazibuko, parliamentary leader of the opposition Democratic Alliance, warned: "This bill will unstitch the very fabric of our constitution. It will criminalise the freedom so many of our people fought for.

"What will you, the members on that side of the house, tell your grandchildren one day? I know you will tell them that you fought for freedom. But will you also tell them you helped to destroy it?

"Because they will pay the price for your actions today. Let this weigh heavy on your conscience as you cast your vote."

More than 1,000 protesters gathered outside the parliament building in Cape Town. Many wore black on what was dubbed Black Tuesday, a reference to Black Wednesday on 19 October 1977 when the apartheid government banned two newspapers and 19 black consciousness movements.

In a rare political intervention, the Nelson Mandela Centre of Memory issued an "expression of concern" about the bill and proposed four amendments. Mandela, 93, has always remained loyal to the ANC, and has almost never intervened since stepping down as the country's president.

Tutu said: "It is insulting to all South Africans to be asked to stomach legislation that could be used to outlaw whistleblowing and investigative journalism … and that makes the state answerable only to the state..

"Please hear the warnings of the academics, civil society leaders, labour representatives, media corps, and legal and constitutional experts. This law will do our people and our country a disservice."

In the past few months, the ANC did accept more than 120 amendments to its original draft but not, crucially, a public-interest defence clause.

When the bill was passed, editors in the parliamentary public gallery walked out in protest.

There was swift condemnation within South Africa and abroad.

Human Rights Watch, in New York, described the move as "a blow to freedom of expression and democratic accountability'. The group said: "Parliament should have heeded the calls of South African civil society, representatives of the media and political opposition, and refrained from holding the vote."

Daniel Bekele, the group's Africa director, added: "The manner in which the government pushed this bill through parliament instead of proceeding with consultations as promised, as well as the secrecy embedded in this legislation, send very worrying signs about the government's commitment to transparency."

The Helen Suzman Foundationexpressed outrage at the vote. "This marks a low point in South Africa's transition to democracy. It represents a significant step backwards in the long walk to freedom to which so many South Africans have devoted their lives."

The group Media Monitoring Africa said it had noted the decision with deep regret and warned that it would be bad for South Africa and its international reputation.

The Times of South Africa on Tuesday carried a black front page with the headline "Not in our name," and a statement signed by 15 national newspaper editors. It began: "Mark this day. Depending on the actions of the 400 MPs in the national assembly at 2pm, it will end as a day of triumph or of shame for our adolescent democracy.

"The spreading culture of self-enrichment, either corrupt, or merely inappropriate, makes scrutiny fuelled by whistleblowers who have the public interest at heart more essential than ever since 1994."

The bill will now move to parliament's upper house before going to the president, Jacob Zuma, to be signed into law. It could face a challenge in the constitutional court.