President Cyril Ramaphosa says South Africa will not be forced to side with any world power.
South Africa's president made the statement as the country prepares to host a summit of major emerging economic powers.
A meeting of the BRICS nations (Brazil, Russia, India, China and South Africa) in Johannesburg this week will aim to expand their influence and spur a shift in global geopolitics.
South Africa's hosting of the summit has drawn attention to its relationship with the Kremlin, particularly as it refuses to condemn Russia's aggression in Ukraine.
Ramaphosa will also be joining Chinese President Xi Jinping, Indian Prime Minister Narendra Modi and Brazilian President Luiz Inacio Lula da Silva at the BRICS summit.
Russia will be represented by Foreign Minister Sergei Lavrov, and President Vladimir Putin will also participate online. Putin decided not to attend in person because he is the subject of an International Criminal Court arrest warrant, which South Africa is theoretically obliged to enforce.
Given South Africa's long-standing relationship with Russia and Russia's refusal to arrest former Sudanese dictator Omar al-Bashir in similar circumstances in 2015, the warrant was issued after Putin's decision was announced. This led to a diplomatic dilemma for several weeks.
About 50 other leaders from non-BRICS countries, including Iran's Ebrahim Raisi and Indonesian President Joko Widodo, confirmed they would attend the talks.
BRICS countries account for about a quarter of the world economy, and interest in joining BRICS has increased this year.
At least 40 countries have expressed interest in joining, and 23 have submitted applications. Countries aiming to join BRICS include Argentina, Bangladesh, Bahrain, Cuba, Ethiopia, Indonesia, Iran, Nigeria, and Saudi Arabia.
South Africa said it supported calls for BRICS countries to open up.
According to South Africa's Foreign Affairs Minister Naledi Pandor, expansion plans were first discussed last year.