The bill was adopted by majority vote after a division was called by the opposition, and a Democratic Alliance motion to delay the vote failed.
All opposition parties present in the House voted against the measure, while hundreds of black-clad activists protested against it outside the gates of Parliament and elsewhere in the country.
The outcome of the vote was 229 in favour and 107 against in the 400-member House. There were two abstentions.
The bill still has to be approved by the National Council of Provinces next year, where DA parliamentary leader Lindiwe Mazibuko said her party would continue the fight for incisive amendments.
If that process failed to produce a new version, she would petition President Jacob Zuma not to sign the bill but to send it back to Parliament.
"But if this bill is signed into law, I will lead an application to the Constitutional Court to have the act declared unconstitutional," Mazibuko threatened.
Like the opposition, media organisations, activists and ANC ally Cosatu have demanded that the bill be redrafted and vowed to challenge it in the Constitutional Court if signed into law in its current form.
All insist that the bill should include a public interest defence, as enshrined in state secrecy legislation in Canada.
Such a defence would enable journalists and others who published classified information under pain of prison to argue in mitigation that they had done so in the public interest.
But State Security Minister Siyabonga Cwele reiterated last week that the ANC would not countenance such a "reckless practice".
The bill criminalises possession and publication of classified information and punishes the latter with up to 25 years’ in prison, if espionage is involved.
It was drafted to replace apartheid-era legislation dating from 1982, but critics say it marks shameful a return to excessive state secrecy less than two decades into democracy.
The editors of 18 daily news publications said in a joint editorial on Tuesday it was "the first piece of legislation since the end of apartheid that dismantles an aspect of our democracy".
Did you take part in "Black Tuesday"? Send us your eyewitness accounts