A South African judge on Sunday banned Sudanese President Omar al-Bashir from leaving the country after the International Criminal Court called for him to be arrested at a summit in Johannesburg.
Bashir, who is wanted for alleged war crimes, crimes against humanity and genocide in the Darfur conflict, mostly travels to countries that have not joined the ICC, but South Africa is a signatory of the court's statutes.
The ruling was the first time any court has prevented a head of state from leaving a country following a request by the ICC, but Khartoum remained defiant, insisting Bashir would return home.
The Southern African Litigation Centre, a legal rights group, had launched an urgent application in the Pretoria High Court to force authorities to arrest Bashir on the opening day of the African Union summit.
"President Omar al-Bashir of Sudan is prohibited from leaving the Republic of South Africa until the final order is made in this application," Judge Hans Fabricius said in his ruling.
"The respondents are directed to all necessary steps to prevent him from doing so."
Despite the arrest calls, Bashir joined a group photograph of leaders at the summit.
Wearing a blue suit, he stood in the front row for the photograph along with South African host President Jacob Zuma and Zimbabwe's President Robert Mugabe, who is the chair of the 54-member group.
In Khartoum, Sudan's State Minister for Foreign Affairs Kamal Ismail said Bashir would return home after the main session of the summit.
"Until now, things are normal and there is no risk to his excellency the president," he said at a news conference.
Mugabe has previously urged African leaders to pull out of the ICC, which critics accuse of targeting Africa.
The ICC said in a statement from its headquarters in The Hague that it "calls on South Africa... to spare no effort in ensuring the execution of the arrest warrants" against Bashir.
It said South Africa diplomats had been pressed last month to arrest Bashir if he attended the summit, but that they replied they faced "competing obligations" over the issue.
Bashir, 71, seized power in Sudan in an Islamist-backed coup in 1989.
"This is a court that is targeting African leaders," Sudan Foreign Minister Ibrahim Ghandour told AFP.
"President Bashir is a leading president, a member of the summit of the African Union and will continue attending the summits wherever they are being held inside Africa."
The ICC indictments relate to the western Sudanese region of Darfur, which erupted into conflict in 2003 when ethnic insurgents launched a campaign against Bashir's Arab-dominated government, complaining of marginalisation.
Khartoum unleashed a bloody counter-insurgency using the armed forces and allied militia.
The United Nations says 300,000 people have been killed in the conflict and another 2.5 million forced to flee their homes.
Khartoum, however, disputes the figures, estimating the death toll at no more than 10,000.
"South Africa has an obligation to arrest him," Johannesburg-based rights lawyer Gabriel Shumba told AFP.
"Failure to do so puts them in the same bracket as other African regimes who have no respect for human rights. It's actually a test for South Africa."
As Judge Fabricius gave his ruling and said the court would meet again on Monday, the summit opened five hours late with Zuma not mentioning the issue in his opening remarks.
"As a member of the International Criminal Court, (South Africa) has committed to cooperate with that court," Elise Keppler of Human Rights Watch told the ENCA news channel.
"This is an incredible moment for South Africa to do the right thing and to render al-Bashir to the International Criminal Court.
"It's quite possible that al-Bashir could in fact be taken into custody before he leaves the country."
The South African government and African Union officials made no comment on the court ruling.
The summit is meeting for two days in the upmarket business and retail district of Sandton under the official theme of the "Year of Women's Empowerment and Development".