(CNN) Senior aides to President Donald Trump knew for months about allegations of domestic abuse levied against top White House staffer Rob Porter by his ex-wives, even as Porter's stock in the West Wing continued to rise, multiple sources told CNN on Wednesday.

Porter denied the allegations but resigned on Wednesday.

A scramble ensued inside the West Wing to defend him when the claims became public this week, the sources said. That effort continues even after his resignation.

Senior White House officials were aware for months of the allegations made against Trump's staff secretary, two sources familiar with the matter said on Wednesday after Porter resigned.

Trump himself first learned of the allegations this week, two sources familiar with the matter said. He was upset when shown reports of the abuse, which first emerged on Tuesday. His daughter Ivanka Trump, serving as a White House senior adviser, was also deeply disturbed by the allegations, particularly by photographs of the alleged abuse, the sources said.

Porter's ex-wives detailed the allegations to the FBI over the course of a routine background check, they told CNN's MJ Lee on Wednesday . A year into the administration, Porter does not hold a security clearance.

By early fall, it was widely known among Trump's top aides -- including chief of staff John Kelly -- both that Porter was facing troubles in obtaining the clearance and that his ex-wives claimed he had abused them. No action was taken to remove him from the staff.

Instead, Kelly and others oversaw an elevation in Porter's standing. He was one of a handful of aides who helped draft last week's State of the Union address. He traveled instead of Kelly to the World Economic Forum in Davos last month. And he was one of a select group of aides who shook Chinese President Xi Jinping's hand during a state visit to Beijing in November.

The White House declined to comment on Wednesday when asked about Kelly's knowledge of the allegations against Porter.

CNN obtained this 2005 photo of Colbie Holderness, who is the first ex-wife of White House staff secretary Rob Porter. Porter resigned on Wednesday, February 7.

In a statement released Wednesday evening, Kelly said he was "shocked" by the "new allegations" against Porter.

"There is no place for domestic violence in our society. I stand by my previous comments of the Rob Porter that I have come to know since becoming Chief of Staff, and believe every individual deserves the right to defend their reputation," Kelly said. "I accepted his resignation earlier today, and will ensure a swift and orderly transition."

Colbie Holderness, Porter's first wife, and Jennifer Willoughby, Porter's second wife, both said their ex-husband's consistent abuse was the reason for their respective divorces.

Porter denied the allegations in a statement issued in the wake of his resignation.

"These outrageous allegations are simply false," Porter said in his statement. "I have been transparent and truthful about these vile claims, but I will not further engage publicly with a coordinated smear campaign."

Intensive defense

The appearance of a top aide accused of abusing two ex-wives led to an intensive defense campaign on Tuesday evening, when the reports first emerged in the Daily Mail . Before the allegations first surfaced on Tuesday, the White House prepared a response defending Porter. Hope Hicks, who serves as the White House communications director and has been romantically involved with Porter, helped draft a supportive statement from Kelly, who spent much of Tuesday on Capitol Hill in immigration talks.

"Rob Porter is a man of true integrity and honor and I can't say enough good things about him. He is a friend, a confidante and a trusted professional. I am proud to serve alongside him," the statement from Kelly read. Hicks worked with White House press secretary Sarah Sanders and Josh Raffel, another White House spokesman who is close to Porter, to draft the statement, people familiar with it said.

Top officials remained staunch in their support of Porter on Wednesday. Kelly, who encouraged Porter to remain in his post despite the allegations, did not alter his effusive statement. Trump himself has "full confidence in his abilities and his performance," according to Sanders.

When Hicks and Kelly discussed the matter on Tuesday, both agreed the White House should defend Porter, sources said. But by the next day, it was evident the show of support wouldn't quiet the controversy.

Neither Porter nor Hicks were present in a Wednesday morning senior staff meeting, a White House official said. The White House press office was sent scrambling after more allegations against Porter were made, and several staffers spent the morning preparing to deal with the fallout.

Kelly, who has relied on Porter to execute a strict system of information control to the President, insisted that he'd be able to weather the allegations and remain in his job, according to a White House official. But Porter resigned anyway, over Kelly's objections. Kelly has long insisted that Porter stay in his job, even as he considered approaches from the private sector, including from Uber, according to one administration source. Uber denies it ever reached out to Porter.

A person familiar with West Wing dynamics said Porter has expressed interest in an elevated policy role over the past weeks, beyond the position he currently holds. Last month he told colleagues that he wasn't planning on leaving the White House to take an outside role.

White House responsibilities

As staff secretary, Porter's responsibility was mainly in the flow of paper that crossed Trump's desk, including the wave of executive orders and actions that Trump inked during the first months of his tenure. A lawyer, Porter also participated in the process of legally vetting the myriad documents that require the President's signature.

Porter's role was under-the-radar, and Trump himself remained largely unfamiliar with him for weeks before his role was explained. The President was impressed by Porter's educational credentials -- including degrees from Harvard and Oxford -- a person familiar with the matter said.

When John Kelly replaced Reince Priebus as White House chief of staff, Porter's role expanded. Kelly -- looking to correct an issue that plagued the White House under Priebus -- imposed a strict system of information flow to the President, elevating the importance of Porter's task in managing the documents, news clippings and briefing books that entered the Oval Office.

Many aides in the West Wing described themselves as shocked at the allegations, which they said are not in character with the mild-mannered lawyer they have worked alongside over the past year.

And some expressed dismay that the allegations against Porter weren't acted upon when senior members of Trump's team became aware of them.

Another uncomfortable moment

It proved another uncomfortable situation for a White House that has been largely out of step with the #MeToo movement that has swept the country. Trump, given the range of sexual harassment and assault allegations against him, has long struggled to respond to the nationwide focus on the mistreatment against women.

During the election, at least 15 women accused Trump of ranging from sexual harassment and sexual assault to lewd behavior around women. They came forward in the wake of a 2005 "Access Hollywood" tape of Trump released in October 2016 caught him saying on a hot mic: "And when you're a star, they let you do it. You can do anything ... Grab them by the p****. You can do anything."

But the White House -- through spokespeople Sarah Sanders and others -- have dismissed all the allegations against him as old news that had been litigated during the 2016 campaign.

Trump told the British broadcaster Piers Morgan in January that he was not a feminist because he was "for everyone."

CNN's Gloria Borger, Dana Bash, Jeff Zeleny, Jeremy Diamond, Jim Acosta and Noah Gray contributed to this report.