Four United Nations deminers arrested by the Sudanese army along the country's tense southern border were released on Sunday and turned over to chief African Union mediator Thabo Mbeki, the defence minister said.
"We release them to President Mbeki," Abdelrahim Mohammed Hussein said in a ceremony at Sudan's military headquarters in Khartoum, more than three weeks after the men were detained.
Mbeki has been in the Sudanese capital since Thursday meeting officials, including President Omar al-Bashir, in an effort to push Sudan and South Sudan back to negotiations which were suspended after border fighting last month.
"I raised your issue with President Bashir and the government explained to us the circumstances of your arrest, and then we asked President Bashir to release you," Mbeki said addressing the four men: a Briton, a Norwegian, a South African and a South Sudanese.
"All of us will go together," he said before the freed men got into a minibus to leave as part of Mbeki's motorcade.
It was not immediately clear whether they were heading directly to the airport.
"We thank the government of Sudan and we appreciate the effort of President Mbeki. We are so happy now that we are going," the Norwegian, John Sorbo, said on behalf of his three colleagues.
Hussein said they were freed because two of them worked for a South African company, "and we appreciate the efforts of President Mbeki to solve the issues between Sudan and South Sudan."
But he accused the four foreigners of "working for one of the parties" because they were captured in a combat zone.
Sudan's army announced on April 28 that it arrested the men in the Heglig oil region as they collected "war debris for investigation," and suggested they were working in support of South Sudan in its "aggression" against the north.
Nationalist feeling has intensified in Sudan after South Sudan seized and occupied the north's main Heglig oilfield for 10 days in April, a move that coincided with Sudanese air strikes against the South.
It was the most serious fighting since the South's independence last July, and raised fears of a wider war. The captives were flown from Heglig and held at a military facility in Khartoum.
Two weeks ago the United Nations announced that the men were UN staff "on a humanitarian demining project in South Sudan". It asked for them to be released into UN custody. -Sapa-AFP