WASHINGTON — A day after Melania Trump took the extraordinary step of issuing a statement condemning Mira Ricardel, the deputy national security adviser who had made enemies throughout her tenure, Ms. Ricardel was spotted in her office on Wednesday, packing her bags.

Hours later, the White House said that Ms. Ricardel was indeed leaving her post but that she would still work in the administration — just not under the first lady’s roof.

“Mira Ricardel will continue to support the president as she departs the White House to transition to a new role within the administration,” Sarah Huckabee Sanders, the White House press secretary, said in a statement. “The president is grateful for Ms. Ricardel’s continued service to the American people and her steadfast pursuit of his national security priorities.”

When a first lady is crossed by an aide, she usually gets results when it comes time to oust that person. Michelle Obama did it. Hillary Clinton did it. But rather than working behind the scenes, Mrs. Trump had her own way of getting her point across.