Entebbe - Sudanese rebels on Sunday released at least 125 prisoners they had captured in fighting with government forces, most of them soldiers, an AFP journalist said.
Their release was secured thanks to mediation from Uganda, while the International Committee of the Red Cross (ICRC) played a facilitating role.
The rebel Sudan People's Liberation Movement-North (SPLM-N) had captured the prisoners in Blue Nile and South Kordofan states, where the group has been fighting Sudanese government forces for years.
The longest-held prisoners had been captured in June 2009 and the most recent about six months ago.
While the ICRC said 125 people had been freed, Sudanese military spokesperson Brigadier Ahmed Khalifa al-Shami put the number at 127 - including 109 soldiers and 18 civilians.
"The Sudanese army recognises this as a positive step towards achieving peace in the country," Shami said in a statement.
Ethnic minority rebels in Blue Nile and South Kordofan have been fighting government forces since 2011, accusing President Omar al-Bashir's Arab-dominated government of politically and economically marginalising the two regions.
Fighting in the two areas and in Darfur has left tens of thousands of people dead and displaced millions.
Khartoum announced a unilateral ceasefire in June 2016 in all three conflict zones, which it extended by six months in January.
The UN officials say that for years Blue Nile and South Kordofan have been no-go areas for aid officials, leaving thousands of people without access to humanitarian relief.
In a statement, the ICRC said it had "facilitated the release and repatriation of 125 people".
The agency said it had transported the released prisoners from South Sudan to Entebbe in Uganda and onward to Sudan.
"The entire transfer operation took place over four days," the ICRC said, adding that it had followed a request from Kampala, Khartoum, Juba and the SPLM-N.
"We are very pleased that these people will finally return to their families," the ICRC's head of delegation in Sudan, Gerard Peytrignet, said.
'No bad treatment'
Speaking to AFP, SPLM-N Secretary General Yasir Arman described the prisoners' release as a humanitarian gesture of goodwill, "to bring happiness to their families".
Mohamed Saied Hassan of the Sudanese foreign ministry told a press conference that 19 of the men were civilian miners caught up in an internal SPLM-N dispute over control of gold mines in Blue Nile state.
However, Arman claimed that the 19 men were members of a militia allied to the government.
The prisoner release negotiations were chaired by officials from the Ugandan government and included direct talks between Ugandan president Yoweri Museveni and Bashir.
Thanking the Ugandan government for mediating the release, Hassan said: "This operation paves the way for more cooperation between the two countries."
Speaking to AFP on the tarmac at Entebbe airport about 35 kilometres (22 miles) from Kampala as he and his men prepared to board the flight to Khartoum, Colonel Lirifat Abdala Ahmed, the most senior captive officer, said he had been treated well since his capture in May 2013.
"There was no bad treatment, no bad behaviour. I have served 25 years in the Sudanese army and now I want to go home to rest," a smiling Ahmed said.