NAIROBI, Kenya - The soldier pointed his AK-47 at the female aid worker and gave her a choice.

"Either you have sex with me, or we make every man here rape you and then we shoot you in the head," she remembers him saying.

She didn't really have a choice: By the end of the evening, she had been raped by 15 South Sudanese soldiers.

Get Breaking News Delivered to Your Inbox

On July 11, South Sudanese troops, fresh from winning a battle in the capital, Juba, over opposition forces, went on a nearly four-hour rampage through a residential compound popular with foreigners, in one of the worst targeted attacks on aid workers in South Sudan's three-year civil war. They shot dead a local journalist while forcing the foreigners to watch, raped several foreign women, singled out Americans, beat and robbed people and carried out mock executions, several witnesses told The Associated Press.

For hours throughout the assault, the U.N. peacekeeping force stationed less than a mile away refused to respond to desperate calls for help. Neither did embassies, including the U.S. Embassy.

The Associated Press interviewed by phone eight survivors, both male and female, including three who said they were raped. The other five said they were beaten; one was shot. Most insisted on anonymity for their safety or to protect their organizations still operating in South Sudan.

The accounts highlight, in raw detail, the failure of the U.N. peacekeeping force to uphold its core mandate of protecting civilians, notably those just a few minutes' drive away. The Associated Press previously reported that U.N. peacekeepers in Juba did not stop the rapes of local women by soldiers outside the U.N.'s main camp last month.

The attack on the Terrain hotel complex shows the hostility toward foreigners and aid workers by troops under the command of South Sudan's President Salva Kiir, who has been fighting supporters of rebel leader Riek Machar since civil war erupted in December 2013.

Army spokesman Lul Ruai did not deny the attack at the Terrain but said it was premature to conclude the army was responsible. "Everyone is armed, and everyone has access to uniforms," he said.

A report on the incident compiled by the Terrain's owner at Ruai's request, seen by the AP, alleges the rapes of at least five women, torture, mock executions, beatings and looting.

The attack came just as people in Juba were thinking the worst was over.

Three days earlier, gunfire erupted outside the presidential compound between armed supporters of the two sides, at the time pushed together under an uneasy peace deal. The violence quickly spread. By Monday, as both sides prepared to call for a cease-fire, some at the Terrain started to relax.

And then the soldiers arrived. A Terrain staffer from Uganda said he saw between 80 and 100 men invade the compound after breaking open the gate.

"They were very excited, very drunk, under the influence of something, almost a mad state, walking around shooting off rounds inside the rooms," one American said.

For about an hour, soldiers beat the American and fired bullets at his feet and close to his head. Eventually, he was told to leave. He made his way to the nearby U.N. compound and appealed for help.

Meanwhile, soldiers were breaking into a two-story apartment block in the Terrain which had been deemed a safe house because of a heavy metal door guarding the apartments upstairs.

The soldiers then sexually assaulted women and shot through the door of a bathroom where several people were hiding, said Jesse Bunch, an American contractor who was hit in the leg.

"We kill you! We kill you!" the soldiers shouted, according to a Western woman in the bathroom. "They would shoot up at the ceiling and say, 'Do you want to die?' and we had to answer 'No!'"

The soldiers found John Gatluak, a South Sudanese journalist. The tribal scars on his forehead made it obvious he was Nuer, the same as opposition leader, Machar.

The soldiers then forced the foreigners to stand in a semi-circle, said Gian Libot, a Philippines citizen.

One soldier ranted against foreigners. "He definitely had pronounced hatred against America," Libot said, recalling the soldier's words: "You messed up this country. You're helping the rebels."

Then Gatluak was hauled in front of the group. One soldier shouted "Nuer," and another soldier shot him dead.

From the start of the attack, those inside the Terrain compound sent email, text and Facebook messages pleading for help.

"All of us were contacting whoever we could contact. The U.N., the U.S. embassy, contacting the specific battalions in the U.N., contacting specific departments," said the woman raped by 15 men.

A U.N. truck drives past displaced South Sudanese families resting in a camp for internally displaced people in the United Nations Mission in South Sudan (UNMISS) compound in Tomping, Juba, South Sudan, July 11, 2016. Beatrice Mategwa/United Nations Mission in South Sudan via Reuters

A member of the U.N.'s Joint Operations Center in Juba first received notice of the attack at 3:37 p.m., minutes after the breach of the compound, according to an internal timeline compiled by a member of the operations center and seen by AP. The timeline shows other appeals for help.

The American who was released requested help from three different U.N. battalions.

"Everyone refused to go. Ethiopia, China, and Nepal. All refused to go," he said.

"The peacekeepers did not venture out of the bases to protect civilians under imminent threat," Human Rights Watch said Monday in a report on abuses throughout Juba.

Eventually, South Sudanese security forces entered the Terrain and rescued all but three Western women and around 16 Terrain staff. A private security firm rescued the rest the next morning.

Asked why U.N. peacekeepers didn't respond to repeated pleas for help, the U.N. said it is investigating.

"Obviously, we regret the loss of life and the violence that the people who were in Hotel Terrain endured, and we take this incident very seriously," the deputy spokesman for the U.N. secretary-general, Farhan Haq, told reporters Monday.

The U.S. Embassy, which also received requests for help during the attack, did not respond to repeated requests for comment.