White House aides and allies are struggling to explain the circumstances surrounding the departure this week of Rob Porter, a top staffer who resigned amid allegations he abused two ex-wives.

Chief of staff John Kelly, long regarded as a moral anchor in the West Wing, took criticism on Thursday from Democrats and even some Republicans for his initial efforts to shield Porter from the controversy, followed by his attempt to distance himself from the disgraced White House staff secretary.

And President Trump’s team has faced questions about the extent to which Porter’s reported girlfriend, White House communications director Hope Hicks, orchestrated his official defense and whether Kelly knew of Porter’s sordid history when he left the aide in a position of influence during a staffing shuffle last year.

Porter cleaned out his desk on Thursday, deputy press secretary Raj Shah said, as scrutiny of his security clearance and his tenure in the White House heated up. Shah admitted the White House “could have done better” in its handling of the controversy, but declined to specify where the communications shop had erred throughout two days of controversy related to Porter’s past.

“Everyone trusted Rob Porter, believed his side of the story and strongly defended him,” one source close to the White House told the Washington Examiner. “However, once pictures surfaced showing physical evidence of abuse, that’s when they had to condemn the behavior.”

Kelly and other White House aides issued statements of support for Porter on Tuesday when the staff secretary’s two ex-wives told the Daily Mail that Porter had physically and verbally abused them during their respective marriages.

But when photographs of one of the women’s black eye surfaced alongside her account of Porter punching her during a vacation, Kelly and others began to walk back their defenses of him.

The chief of staff’s amended statement noted he was “shocked” by the latest set of allegations against Porter while standing by “previous comments about the Rob Porter that I have come to know.” Kelly’s original statement had applauded Porter’s job performance without condemning the claims from his ex-wives.

Even as the White House unveiled Porter’s resignation on Wednesday, aides continued to praise his contributions to the administration and downplay the immediacy of his departure.

"He is going to be leaving the White House. It won't be immediate," Sanders told reporters on Wednesday.

The administration’s tone had shifted by Thursday morning, however, as the graphic images of the battered face of Porter’s ex-wife sparked outrage and stoked speculation about how much Kelly knew of the situation prior to the stories that erupted this week.

“This doesn’t hurt Gen. Kelly because no one really knew there were two sides to Porter,” said the source close to the White House.

But another person close to the White House said the details surrounding Porter’s departure had him “gravely concerned.”

“Since Trump’s been in office, this is the first time I’ve been concerned about anything going on in the White House regarding the storyline,” the person said, noting the other politicized controversies that have dogged the West Wing have not carried the same weight

As staff secretary, Porter presided over much of the material that reached Trump’s desk on a daily basis. That task should have required him to maintain a high-level security clearance, because he saw much of the same sensitive information the president ultimately saw when he held the position.

The White House has refused to answer questions this week about how Porter was able to obtain an interim security clearance and why the duration of the processing time for a permanent clearance did not raise any red flags with Kelly or other senior aides.

Both of the women who accused Porter of abuse said FBI agents interviewed them months ago as they performed a standard background check on the staff secretary. Both women said they passed along their tales of verbal and physical abuse.

“His background investigation was ongoing. He was operating on an interim security clearance. His clearance was never denied, and he resigned,” Shah told reporters on Thursday.

Three Senate Democrats requested an investigation on Thursday into the process by which Trump aides have received their security clearances as scrutiny of Porter’s access to classified information mounted.

Although Trump was said to be upset by the allegations against one of his closest aides, the White House made clear on Thursday that the president remains confident in Kelly, who has taken heat for standing by Porter before issuing a clarifying statement that critics perceived to be too weak on the accused abuser.

Trump and Kelly have had a number of tense moments in their relationship in recent weeks. For example, the president reportedly bristled at Kelly’s argument last month that Trump’s campaign promises on immigration were “not fully formed.”

The White House also struggled on Thursday to explain Hicks’ involvement in shaping the defense for a man with whom she has been romantically linked.

Shah said the communications director “did recuse herself from some matters concerning” Porter’s defense, but declined to specify which elements.