South Africa has told the United Nations it is going to withdraw from the International Criminal Court (ICC), having formally begun the process.
The country's justice minister Michael Masutha said a bill would be put before parliament.
Mr Masutha said membership of the international court stopped South Africa playing its role as regional peace broker, if it could not guarantee diplomatic immunity to visiting leaders.
Last year, a South African court criticised the government for refusing to arrest the Sudanese president, Omar al-Bashir, who is wanted by the ICC on charges of genocide and war crimes.
He denies allegations that he committed atrocities in Sudan's troubled western Darfur region.
The government ignored an ICC request to arrest Mr Bashir when he was attending an African Union summit in Johannesburg.
A government minister said South Africa did not want to execute ICC arrest warrants which would lead to "regime change".
Several media outlets have obtained a copy of the "Instrument of Withdrawal", signed by South Africa's foreign minister.
"The Republic of South Africa has found that its obligations with respect to the peaceful resolution of conflicts at times are incompatible with the interpretation given by the International Criminal Court," the document says.
Rome Statute 'incompatible'
Mr Masutha said the government would table legislation in parliament to withdraw South Africa from the ICC.
The Rome Statute, under which the ICC was set up, requires the arrest of heads of state for whom a warrant had been issued.
But the justice minister said the result of that would be "regime change" and the statute was incompatible with South African legislation that gave heads of state diplomatic immunity.
The ICC has a notoriously fractious relationship with the African continent.
Despite 34 African nations signing up to the court's jurisdiction, a handful of governments have recently decided their idea of international justice is incompatible with that laid out in the Rome Statute.
When the Kenyan President, Uhuru Kenyatta, was charged with crimes against humanity, the African Union argued that heads of state should be entitled to immunity for the duration of their term in office.
This was in direct contravention of the ICC's raison d'etre - to hold the most powerful to account. The trial against Mr Kenyatta later collapsed because of a lack of evidence.
The African Union invited the Sudanese president to a summit in Johannesburg, but he disappeared during dinner after resounding calls from human rights groups for him to be detained in line with the outstanding arrest warrant issued by the ICC.
Nine out of 10 of the ICC's current investigations are in Africa - leading to allegations of bias against African countries.
If South Africa continues with the process of pulling out of the ICC it could create a domino effect, and threaten the future of the world's first permanent war crimes court.
Human Rights Watch has criticised South Africa's decision.
"South Africa's proposed withdrawal from the International Criminal Court shows startling disregard for justice from a country long seen as a global leader on accountability for victims of the gravest crimes," said Dewa Mavhinga, the organisation's Africa division senior researcher.
"It's important both for South Africa and the region that this runaway train be slowed down and South Africa's hard-won legacy of standing with victims of mass atrocities be restored," Mr Mavhinga said.