Ratings agency Moody's on Friday night kept South Africa's sovereign debt at above investment grade, and changed its outlook to stable.
The announcement was made at 23:35.
"The confirmation of South Africa's ratings reflects Moody's view that the previous weakening of South Africa's institutions will gradually reverse under a more transparent and predictable policy framework," the agency said in a credit rating announcement.
"The recovery of the country's institutions will, if sustained, gradually support a corresponding recovery in its economy, along with a stabilisation of fiscal strength."
If Moody's had downgraded the credit rating on SA's debt, the country would have automatically been removed from the Citi World Government Bond Index, forcing asset managers to sell SA bonds. This would have resulted in billions of rands leaving the country.
The rand, which opened at 11.85/$ on Friday morning, was trading at R11.74 to the greenback shortly after the announcement.
While its rival ratings agencies Fitch and S&P both downgraded SA to junk last year, Moody's had in November 2017 maintained its sovereign rating for SA at Baa3, one rung above junk status. At the time it placed the rating on review for downgrade. On Friday it said SA's rating would remain at Baa3 with a stable outlook.
National Treasury in a statement welcomed the decision, saying government was working to improve the country's investment and economic prospects by providing policy certainty.
"The rating action by Moody's demonstrates that South Africans working together can achieve remarkable outcomes," it said.
Cautious optimism justified
Before the rating announcement was made, top Treasury officials and SA business bodies had been cautiously optimistic that Moody's would keep SA Inc at above investment grade.
This followed an investor roadshow to the UK and US last week, where a SA delegation of government, business and labour officials met with the three major ratings agencies, including Moody's.
On Thursday Deputy Finance Minister Mondli Gungubele said at a meeting of public policy makers and business leaders in Johannesburg that Treasury had recently conducted "very frank and honest discussions" with ratings agencies. "As a result of that, I anxiously, and with all humility expect something better, but that is their decision to make."
Business Leadership South Africa CEO Bonang Mohale told Fin24 by phone from New York earlier in the week that the mood of ratings agencies around recent developments in SA "seems to be positive".
Market analysts, meanwhile, had suggested that the relative strength of the rand had indicated that investors were already pricing in the likelihood that SA's credit rating will not be further downgraded.