The report from a UN special investigation found that a lack of leadership in the UN mission culminated in a "chaotic and ineffective response" during the heavy fighting in the capital from July 8 to 11.
Peacekeepers abandoned their posts and failed to respond to pleas for help from aid workers under attack in a nearby hotel, according to a summary of the report.
The UN mission known as UNMISS has 16,000 troops deployed in South Sudan, which has been at war since December 2013.
Chinese peacekeepers abandoned their positions at least twice and Nepalese peacekeepers failed to stop looting inside the UN compound, the inquiry found.
More From This Section
Ban said he was "deeply distressed by these findings" and "alarmed by the serious shortcomings identified by the special investigation."
The UN chief "has asked for the immediate replacement of the force commander," said Dujarric, adding that other measures would follow.
Lieutenant General Johnson Mogoa Kimani Ondieki of Kenya had been the force commander since May.
Machar fled the capital during the violence that derailed international efforts to form a unity government and restore peace to South Sudan.
The investigation led by retired Dutch general Patrick Cammaert was unable to verify allegations that peacekeepers did nothing to help women who were raped near the UN base during the heavy fighting.
But in a later incident on September 2, a woman was assaulted near the entrance to a UN compound "in plain sight" of the peacekeepers, the report said.
After the crisis, peacekeepers "continued to display a risk-averse posture unsuited to protecting civilians from sexual violence" and other attacks, said the report.
UNMISS soldiers refused to conduct foot patrols near UN bases and instead would "peer out from the tiny windows of armored personnel carriers, an approach ill-suited to detecting perpetrators of sexual violence and engaging with communities to provide a sense of security.