Rival leaders in South Sudan have formed a transitional coalition government, in an attempt to end years of ruinous conflict that has killed almost 400,000 and forced millions from their homes.

Opposition leader Riek Machar was sworn in on Saturday in the capital, Juba, as the first deputy of President Salva Kiir a day after the previous government was dissolved.

"I do hereby swear that I shall be faithful and bear diligence to the Republic of South Sudan," Machar said in his oath in front of a room packed with diplomats and regional representatives, including Sudanese leader General Abdel Fattah al-Burhan.

More:

Amid applause, Machar embraced and shook hands with Kiir.

For his part, Kiir declared "the official end of the war, and we can now proclaim a new dawn". Peace is "never to be shaken ever again", the president said, adding that he had forgiven Machar and asking for Machar's forgiveness, to applause. He called on their respective Dinka and Nuer ethnic groups to do the same.

Kiir and Machar started out as president and deputy at independence from Sudan in 2011. But two years later, Kiir sacked Machar and later accused him of attempting a coup against him, sparking a bloody war characterised by ethnic conflict.

A 2015 peace deal brought Machar back as vice president and he returned to Juba amid heavy security.

When that deal fell apart in July 2016, the capital was plunged into a brutal battle between rival armies and Machar was forced to flee on foot. The ensuing war drew in new parts of the country and other local grievances and disputes came to the fore.

Despite intense international pressure following the most recent peace deal in 2018, Kiir and Machar in the past year pushed back two deadlines to take the crucial step of forming the coalition government.

But with less than a week before the latest deadline on Saturday, each made a key concession. Kiir announced a "painful" decision on the politically sensitive issue of the number of states, and Machar agreed to have the president take responsibility for his security. On Thursday, they announced they had agreed to form a government meant to lead to elections in three years - the first vote since independence.

Al Jazeera's Hiba Morgan, reporting from Juba, said war-weary South Sudanese are expecting the government to resolve a number of pressing challenges.

"The people on the streets are looking to this government to solve the issue of the economy - South Sudan is facing high inflation as a result of the years of conflict," Morgan said.

"There is also the issue of the humanitarian crisis; more than half of the country's 12 million population are in need of food aid to survive."

'Important milestone'

Kiir and Machar have said outstanding issues will be negotiated under the new government.

Tens of thousands of rival forces still must be knitted together into a single army, a process that the United Nations and others have described as being behind schedule and poorly provisioned.

Observers have stressed that this new government must be inclusive in a country where fighting has often occurred along ethnic lines and where several armed groups operate. Not all have signed on to the peace deal.

Other vice presidents named by Kiir on Friday include Taban Deng Gai, a former ally of Machar who switched to the government side and last month was sanctioned by the United States over involvement in serious human rights abuses. Another is Rebecca Garang, the widow of John Garang, who led a long fight for independence from Sudan.

The humanitarian community, which has seen more than 100 workers killed since the civil war began, hopes the new government will lead to far easier delivery of food and other badly needed support.

Some 40,000 people are in famine conditions, a new report said on Thursday, and now a major locust outbreak in East Africa has arrived.

More than two million people fled South Sudan during the civil war, and Kiir has urged them to return.

The UN Commission on Human Rights in South Sudan has warned that serious abuses continue.

"Today in South Sudan, civilians are deliberately starved, systematically surveilled and silenced, arbitrarily arrested and detained and denied meaningful access to justice," its latest report said.

It noted that scattered deadly violence, the use of child soldiers, repression and sexual violence imperil the fragile peace.

"While much work remains to be done, this is an important milestone in the path to peace," the US embassy said in a congratulatory message.