Johannesburg stocks rose nearly 1 percent on Tuesday, as investors returned to resource heavyweights African Rainbow Minerals, BHP Billiton and other shares that have been battered down in a recent sharp sell off.

Stocks briefly pared some gains in late afternoon trade after South Africa's parliament passed a state secrecy bill that critics charge could dent the country's long-term reputation among foreign investors.

Continued concerns about the debt crisis in both the United States and Europe also helped cap gains, traders said.

It's a bit of a wait and see, unfortunately, a lot of damage has been to the charts technically and if we don't see a recovery soon we are pointing to more downside, said Devin Shutte, an equity and derivatives trader at Newstrading.

South Africa's benchmark Top-40 index finished up 0.97 percent at 28,002.10, just above the psychologically important level of 28,000. The index booked its biggest one-day drop in 7 weeks on Monday, tumbling 2.5 percent.

The All-share index, the widest measure of South African stock performance, rose 0.8 percent to 31,369.74.

African Rainbow Minerals, a diversified miner with assets in coal, base metals and platinum, rose 2.1 percent to 172.60 rand. Shares of the company fell nearly 4 percent in the previous session and dropped nearly 7 percent in the five sessions to Monday.

BHP Billiton, the global miner, rose 1.2 percent to 235.96 rand. Shares of the company fell 3.7 percent on Monday.

WORRIES ABOUT BILL

Parliament's passage of bill protecting state secrets could be seen as a negative by foreign investors calling for more transparency in Africa's biggest economy, traders said.

Critics believe it will hide graft from public view and intimidate those that try to expose it.

Shares briefly pared some gains after the bill was passed while the rand took a knock on the news as well, easing nearly 1.5 percent to a nine-week low.

Foreigners are looking at it as quite a negative, said Bernhard Grobler, Investec's head of stockbroking in Johannesburg.

They would be taking money out of the country as a result of that, having a negative effect on our equity market. Probably we would see a flow out of bonds as well.

Ratings agency Moody's has downgraded South Africa's outlook, saying it is worried about increasing government interference in the economy, while the country has been sliding in Transparency International's gauge of perceived corruption from 38th in the world in 2001 to 54th in 2010.

Gold stocks gained, helped in part by a recovery in the price of the precious metal. Harmony Gold, South Africa's third-largest gold producer, gained 3.76 percent to 109.49 rand,

while bigger rival AngloGold Ashanti was 2.4 percent stronger at 374.85 rand.

Shares traded stood at 202 million, according to preliminary data available from the Johannesburg exchange at 1516 GMT. A total of 207 million shares changed hands on Monday.

Nearly half of the 350 counters on the bourse gained, 122 shed value and 79 remained unchanged.