South Sudan rebel leader Riek Machar was sworn in as first vice-president on Saturday, formally rejoining the government in the latest bid to bring peace to a nation ravaged by war.

President Salva Kiir hailed the “official ending of war” and said peace was now “irreversible” as the new unity government was formed after more than a year of delays and bickering over crucial issues.

It is the third time that bitter foes Machar and Kiir will attempt to rule together and the pair has many differences yet to iron out as they form a government that is a cornerstone of a September 2018 peace deal.

“For the people of South Sudan, I want to assure you that we will work together to end your suffering,” Machar said after taking the oath and embracing Kiir.

The rebel leader returns as first vice-president in a transition government which will serve for 36 months.

Four other vice-presidents from the current regime and other opposition groups will also form part of a bloated government of 35 ministers, in addition to 550 lawmakers.

The rivals started out similarly as president and deputy at independence in 2011 but Kiir sacked Machar in 2013 and later accused him of attempting a coup against him, sparking a war characterised by ethnic bloodshed between Kiir’s Dinka and Machar’s Nuer communities.

“We must forgive one another and reconcile. I also appeal to the people of Dinka and Nuer to forgive one another,” said Kiir.

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.

After six years of war, some 380,000 people have died, and four million fled their homes, half of them into neighbouring countries in Africa’s worst refugee crisis. More than half the population is facing severe hunger.

The deal was welcomed by rights groups, the EU and UN refugee chief, who all highlighted the long and difficult road ahead.

“There are major challenges ahead. In particular, the transitional security arrangements are still at an early stage and need re-orienting,” an EU statement said.

UN High Commissioner for Refugees Filippo Grandi said: “Millions of South Sudanese – including refugees and internally displaced people, deserve to see an end to their miseries”.

Human Rights Watch Africa director Jehanne Henry urged the new government to “quickly set out a human rights agenda that includes reforming the abusive national security service, freeing abducted civilians held by armed groups, and establishing a hybrid war crimes court in partnership with the African Union”.

The economy of the oil-rich nation is shattered, infrastructure and roads barely exist, and millions of children are out of school.

The September peace deal has led to the longest period of relative calm since 2013 but fighting continues between government and holdout rebel groups in the Central Equatoria region.

Bloody localised conflicts between communities in the absence of a functioning state have also soared.

And, with around 190,000 people still cowering in UN protection camps around the country, the UN special envoy to South Sudan David Shearer said he believed that “we will see lots of people once displaced moving back to their homes”.