The army celebrates in Bor - a town that has changed hands several times
South Sudan's military says it has recaptured the strategic town of Bor from rebel forces.
The Ugandan army said it had helped in the operation, while a spokesman for the rebel forces said its troops had made a tactical withdrawal.
Bor, the capital of Jonglei state, has changed hands several times in a month-long conflict that is believed to have left thousands dead.
Meanwhile, talks to try to find a ceasefire are continuing in Ethiopia.
The conflict between rebel and government forces broke out on 15 December. President Salva Kiir has accused his former deputy Riek Machar of plotting a coup - an accusation he denies.
The dispute has seen killings along ethnic lines - Mr Kiir is a member of the Dinka community, the country's largest, while Mr Machar is from the Nuer ethnic group.
Hundreds of thousands of people have been displaced by the fighting.'Ghost town'
On Thursday, Ugandan President Yoweri Museveni confirmed his country's troops were now fighting alongside South Sudanese government forces against the rebels. A spokesman for the Ugandan People's Defence Force said its troops had helped retake Bor.
Hundreds of thousands of people have been displaced by the fighting
"There was a lot of resistance but our force was overwhelming," the spokesman, Paddy Ankunda, told Reuters news agency.
South Sudanese army spokesman Philip Aguer said the fight for Bor had left "many dead", without giving figures.
Brig-Gen Lul Ruai Koang, a military spokesperson for the opposition in South Sudan, said its troops had withdrawn to reorganise.
Some refugees have moved to the Ugandan town of Adjumani, 470km north of the capital Kampala
He said Bor was a "ghost town" and no longer important.
But Col Aguer said the victory had eliminated the psychological pressure of a rebel attack on the capital, Juba, 200km (130 miles) south of Bor.
Col Aguer also said the focus would now fall on the town of Malakal, still party controlled by the rebels, with the government forces planning an imminent attack.
But Col Aguer admitted maintaining communication with government forces there was "difficult".
The BBC's Mark Lowen, in Juba, says Bor has changed hands a number of times already - and it is not inconceivable that Riek Machar could mobilise his forces for another assault.
Talks to try to agree a ceasefire are continuing in a hotel in the Ethiopian capital, Addis Ababa.
There have been conflicting reports about progress in the discussions, but no breakthrough has yet been signalled.
Our correspondent says it is widely believed that the talks have stalled because both sides are aiming for an upper hand in the fighting before real negotiations begin.
The release of political detainees continues to be a key issue that must be resolved.
On Friday, UN Human Rights fact finder Ivan Simonovic said both government soldiers and rebels had committed atrocities.
He told the BBC there had been reports of "mass killings, extra-judicial killings, arbitrary detention, enforced disappearances, sexual violence, widespread destruction and #####ng of property and use of the children in conflict".
Fighting erupted in the South Sudan capital, Juba, in mid-December. It followed a political power struggle between President Salva Kiir and his ex-deputy Riek Machar. The squabble has taken on an ethnic dimension as politicians' political bases are often ethnic.