Sudan has endorsed the African Union's (AU) roadmap to avert an all-out war with South Sudan, though it insisted on retaining the right to self-defence.
Earlier on Thursday, South Sudan said it had accepted the AU's seven-point roadmap that called for a cessation of hostilities.
Based on the seven-point roadmap, the two countries have until next Tuesday to restart stalled negotiations and three months to reach an agreement.
The AU is trying to get the two sides to again negotiate the countries' shared border, citizenship matters and oil revenue sharing.
The UN Security Council on Wednesday unanimously passed a resolution threatening Khartoum and Juba with sanctions if they failed to silence the guns and resume talks within two weeks, endorsing the AU's deadline of May 8.
The Sudanese Foreign Ministry issued a statement on Thursday accepting the AU plan as well as the UN resolution. But with its reference to self-defense, the Sudanese statement also implied possible continued conflict.
The statement said Sudan wished the other side would fully commit to stopping hostilities and would withdraw its troops from disputed areas so that Sudan could do the same.
The foreign ministry also said Khartoum was committed to a long-standing peace with the South and hoped Juba would cooperate with the AU and Security Council decisions.
The AU's plan also calls for Sudan and South Sudan to withdraw troops from contested areas and resume talks with the aim of resolving all outstanding disputes.
Neither can afford a protracted, full-blown conflict but distrust runs deep between them, especially after the South gained independence from its northern neighbour last July under a 2005 peace deal that ended two decades of civil war.
The breakaway left tens of thousands of South Sudanese stranded as foreigners in Sudan. Sudan's government initially gave them until April 8 to get the right papers or leave.
The Sudanese government issued a May 5 departure deadline for up to 12,000 South Sudanese stuck in the port of Kosti, hoping to leave by Nile barge. But Khartoum then halted river traffic because it said South Sudan was using it to transport weapons to rebels.
The May 5 deadline prompted an outcry from the United Nations and the International Organisation for Migration. The government said late on Wednesday the South Sudanese now had until May 20 to leave.