The civil war in South Sudan is flaring up again, and the security situation in the country is becoming more dire by the day. Reports are surfacing of increasing brutality against civilians caught between the government and opposition fighters, who are divided largely along ethnic lines.

Last month, troops loyal to President Salva Kiir raided a compound housing foreign aid workers in the capital Juba. They beat and raped residents and killed a local journalist, all while United Nations peacekeepers less than a mile away did nothing even after being called to help. That's according to a chilling report from the Associated Press.

The raid, on July 11, came after days of clashes in Juba between the two sides. According to Human Rights Watch, civilians were targeted too, and rape and looting were commonplace — most, according to the watchdog group, by government troops.

The conflict has claimed the lives of more than 50,000 people since December 2013, according to a UN official, left more than 2.5 million displaced, and made it difficult for half the population to find food.

At a glance, the conflict would seem to be a war between the two biggest ethnic groups in South Sudan, the Dinka and the Nuer. The journalist killed in the compound raid, for example, was shot immediately after being identified as a Nuer by Dinka soldiers.

And, indeed, a United Nations report says that "tribal fissures" are "deepening" in South Sudan; the army, military intelligence, and other security organs are "increasingly dominated by members of the Dinka tribe."

But the civil war has its roots in a conflict that began decades ago and touches on control of land and natural resources, including a vast oil wealth. When South Sudan gained independence from Sudan in 2011, it got most of the oil fields, while Sudan controlled the means of exporting the oil, setting the stage for a war that has often focused on oil-producing areas.

Sudan was born in 1956 when it won independence from Anglo-Egyptian joint rule, creating a country that was the largest in Africa and also divided between a largely Muslim north, and a Christian and animist south. Conflict between government forces and southern rebel groups, rooted in divisions over how the new state should be organized, broke out soon after.

In 2005, after two civil wars in which more than 2.5 million people died, an agreement was reached for a permanent ceasefire, a joint government, more autonomy for the South, and the guarantee of an independence referendum in 2011. When that referendum was held, 99 per cent of South Sudanese voters chose independence, and the Republic of South Sudan was officially born in July of that year.

But the seeds of another conflict had been planted during the struggle for South Sudan's independence. The South Sudanese accused the Sudan government of arming various ethnic groups to sow discord, particularly between the Dinka and Nuer.

Historical enmity between the two over resources such as land and water turned into a full-out war after the firing in July 2013 of vice president Riek Machar, a Nuer, by president Salva Kiir, a Dinka.

This set off a conflict that, while couched in ethnic terms, was in fact mostly political, according to BBC analysis. Support for Kiir and Machar was not restricted to their respective ethnic groups, and fighting often raged around control of oil, which accounts for 98 percent of South Sudan's budget.

"What began as a political conflict between elites that exploited tribal tensions has evolved in the past 10 months into a zero-sum struggle where the exclusion of competing tribal groups from political power has become a principal aim of many protagonists," said a UN Panel of Experts on South Sudan in a January 2016 letter.

"The conflict is therefore not a simple, binary competition between the Government and SPLM/A in Opposition and their respective tribal bases," the experts wrote, using the acronym for Machar's armed faction. It is instead "a multifaceted war where allegiances shift rapidly depending on access to resources, unaddressed grievances and the opportunity for individual politicians and military commanders to exploit the situation to press for military and political advantage."

There was a short-lived ceasefire in 2014, to allow for peace talks held in neighboring Ethiopia. In August 2015, Kiir, pressured by a threat of UN sanctions, signed a peace deal allowing Machar to return to South Sudan as the vice president in a unity government. This finally happened in April 2016, but Machar was replaced in July as the head of his faction, and sacked from the vice presidency.

Hundreds have been killed since, with both sides accused of human rights violations. The United Nations says in its report that those crimes are sanctioned by leaders.

"There is clear and convincing evidence ... that most of the acts of violence committed during the war by the Government or by government-affiliated forces, including the targeting of civilians and violations of international humanitarian law and international human rights law, have been directed by or undertaken with the knowledge of senior individuals at the highest levels of the Government," the UN experts wrote. The same is true for the opposition, they added.

On the ground, meanwhile, confusion reigns as to who might do anything to stop the bloodshed. The UN maintains a sizeable multinational contingent headquartered in Juba, with more than 10,000 soldiers, currently commanded by an Ethiopian general. But on July 11, the UN did not send help when a call came from the nearby compound under attack.

"We are deeply concerned that United Nations peacekeepers were apparently either incapable of or unwilling to respond to calls for help," the US ambassador to the United Nations, Samantha Power, said in a statement. The UN has opened an investigation.

The US embassy also received requests to intervene on that day, but State Department spokesperson Elizabeth Trudeau said it was not able to do so, and that the ambassador contacted South Sudanese government officials instead.

The SPLM/A opposition forces denied any involvement in the July 11 attack on the compound. Kiir, in a speech on Monday to the Transitional National Legislative Assembly, said the accusations are being investigated.