Arresting Vladimir Putin would amount to a declaration of war on Russia, South African President Cyril Ramaphosa wrote in court papers released on Tuesday as the country wrangles over hosting the Russian leader.
Putin has been invited to a BRICS summit in Johannesburg next month but is the target of an International Criminal Court arrest warrant -- a provision that Pretoria as an ICC member would be expected to implement were he to attend.
South Africa's diplomatic dilemma is playing out in court, where the leading opposition party, the Democratic Alliance (DA), is trying to force the government's hand and ensure the Kremlin leader is held and handed over to the ICC if he steps foot in the country.
But in a responding affidavit, Ramaphosa described the DA's application as "irresponsible" and said national security was at stake.
"Russia has made it clear that arresting its sitting President would be a declaration of war," he said.
"It would be inconsistent with our Constitution to risk engaging in war with Russia," he said, adding that this would go against his duty to protect the country.
South Africa is seeking an exemption under ICC rules based on the fact that enacting the arrest could threaten the "security, peace and order of the state," he said.
South Africa is the current chair of the BRICS group, a gathering of heavyweights that also includes Brazil, Russia, India and China, which sees itself as a counter-balance to Western economic domination.
Putin is sought by the ICC over accusations that Russia unlawfully deported Ukrainian children.
Deputy South African President Paul Mashatile has said in recent interviews with local media the government has been trying to persuade Putin not to come -- but so far unsuccessfully.
Signed in June and initially marked as "confidential", Ramaphosa's affidavit was published on Tuesday, after the court ruled related papers be made public.