South Sudan said on Friday it would withdraw its troops from the disputed Heglig oil region more than a week after seizing it from Sudan, pulling the countries back from the brink of war.
Sudan said it had already liberated the area, as state television showed footage of hundreds of people gathered in the streets of Khartoum chanting, cheering and waving flags.
South Sudan's seizure of the territory had raised the prospect of two sovereign African states waging war against each other openly for the first time since Ethiopia fought newly-independent Eritrea in 1998-2000.
Tensions have been rising since South Sudan split away from Sudan as an independent country in July, under the terms of a 2005 settlement, taking with it most of the country's known oil reserves.
The countries have still not agreed on the exact position of their shared border and the dispute between them has already halted nearly all the oil production that underpins both economies.
South Sudan President Salva Kiir ordered the unconditional withdrawal of his troops within three days, the country's information minister told reporters in the southern capital Juba.
The Republic of South Sudan announces that SPLA (southern army) troops have been ordered to withdraw from Panthou (Heglig), Barnaba Marial Benjamin said.
Benjamin said the withdrawal was in response to appeals from world leaders and to create an environment for the resumption of dialogue with Sudan. U.N. Secretary-General Ban Ki-moon called for the South to pull out on Thursday.
The South still believes Heglig, which many southerners call Panthou, was its rightful territory and wanted its status to be determined by international arbitration, Benjamin added.
In Sudan, where television channels were playing bellicose military-themed montages, the defence minister said the armed forces were able to liberate Heglig and clear it of South Sudan's forces and mercenaries.
We in the armed forces are ready to continue the operation to its limits until we reassure the Sudanese people, Abdel Raheem Muhammad Hussein said in a speech broadcast on state television.
The armed forces moved ... to preserve what is left of the oil facilities, he said.
Philip Aguer, spokesman for South Sudan's army, said Sudan had bombarded Heglig on Thursday, caused the central processing facility to catch fire.
A MiG yesterday bombed oil facilities in Heglig and one facility was hit, the central processing facility, which separates water from crude oil, he said. It caught fire yesterday and was burning.
Limited access for independent journalists to Sudan's remote conflict zones makes it difficult to confirm the often contradictory claims issued by all sides.
Heglig was central to Sudan's economy because it produced about half of the 115,000 barrel-per-day oil output that remained in the country after the South seceded.
An oil official on Wednesday said Sudan had lost about 40,000 barrels per day of output as a result of the fighting.
The landlocked South shut down its roughly 350,000 barrels per day of output in January in a dispute with Khartoum over how much it should pay to export via pipelines, a Red Sea port and other infrastructure in Sudan. Much of South Sudan's oil was routed through the Heglig processing plant until the shutdown.
The south secured its independence in a referendum promised in the 2005 peace accord that ended decades of civil war between Khartoum and the south. Religion, ethnicity and oil fuelled the conflict that killed about 2 million people.
(Reporting by Khalid Abdelaziz, Ulf Laessing, Hereward Holland and Alexander Dziadosz; Writing by Alexander Dziadosz; Editing by Andrew Heavens)