Mali will next month become the first national football team to play in South Africa since xenophobic violence there claimed at least 12 lives during September.
Zambia cancelled a friendly against South Africa in Lusaka this month because they could not guarantee the safety of the visitors after attacks on African economic migrants around Johannesburg sparked continent-wide fury.
Madagascar initially agreed to visit South Africa as replacements for Zambia, then abruptly withdrew.
The announcement that Mali had agreed to play a friendly international against South Africa was made in coastal city Port Elizabeth, where the match will be staged on October 13.
South Africa and Mali will be competing for the Nelson Mandela Challenge trophy at a stadium named after the first democratically elected president of the republic, who died in 2013.
The 45,000-seater was built for the 2010 World Cup and is now the home ground of top-flight club Chippa United and Pro14 rugby union club Southern Kings.
Both countries are preparing for the start of the 2021 Africa Cup of Nations qualifying group phase during November.
South Africa play Ghana away and Sudan at home in Group C while Mali host Guinea and visit Liberia or Chad in Group A.