Four UN deminers arrested by the Sudanese army along the country's tense southern border were released 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.
The former South African president 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.
"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.
The captives appeared to be in good condition but their shoes were dirty.
They smiled and shook hands with the defence minister and Sudanese military officers.
Diplomats said the captives were later turned over to their respective embassies.
"The UN will take over the rest of the arrangements," South African ambassador Graham Maitland told AFP as he met with his freed countryman Thabo Siave.
The United Nations has identified the men as its staff, and asked for them to be released to the United Nations.
Norwegian ambassador Jens-Petter Kjemprud said they would leave Sudan under UN auspices, "on the first available flight" back to their base in South Sudan.
"They all appreciate the way they have been treated while they were in custody," Kjemprud told AFP.
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 Hussein 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.
They were under investigation because they illegally crossed the border into a military area, and had military equipment with them, the foreign ministry said.
The South African demining company Mechem has described the capture as an "abduction" by the Sudanese military while the group, including its employees Siave and the unidentified South Sudanese, were on a UN landmine clearance contract in South Sudan.
The border in the area is unmarked and disputed.
On May 2 the UN Security Council gave Sudan and South Sudan two days to cease hostilities and two weeks to unconditionally resume negotiations on critical issues left outstanding after the South separated last July following decades of civil war.
The UN has threatened sanctions if its demands are ignored.
Bashir and his defence minister are both wanted by the International Criminal Court for alleged crimes against the people of Darfur in Sudan's west.