Not that immigration was the only issue on which Ms. Nielsen floundered. On the critical question of Russia’s meddling in the 2016 elections, she was even less lucid. At times, she seemed to support the intelligence community’s findings that the Kremlin had been up to no good. Other times, she supported the view that Russia had not favored Mr. Trump in the election. Her every utterance seemed intended to obfuscate rather than to clarify.

Ms. Nielsen’s departure is part of a broader purging in her department. Two days before meeting with the secretary, the president withdrew his nomination for the next head of the Immigration and Customs Enforcement agency, saying that he wanted to go in a “tougher direction.” On Monday, the White House confirmed that Randolph Alles, the head of the Secret Service, was on his way out as well. The general counsel for Homeland Security, John Mitnick , and the head of Citizenship and Immigration Services, L. Francis Cissna , are expected to soon follow.

For now, Ms. Nielsen’s acting replacement will be Kevin McAleenan, the commissioner of Customs and Border Protection. This leaves Homeland Security without a top official at either of its critical immigration agencies. It comes as the swell of migrant families across the border pushes the system toward collapse. Possible successors being discussed include Rick Perry, the secretary of energy, and Ken Cuccinelli, the former attorney general of Virginia.

Whoever takes Ms. Nielsen’s place, it seems likely that greater influence will be exerted by Mr. Miller, who inspires and reinforces Mr. Trump’s harshest impulses on immigrants and immigration. As the president becomes increasingly agitated about the border situation, Mr. Miller is said to be aggressively pushing to stock the administration with like-minded hard-liners. In addition to being a longtime critic of Ms. Nielsen, Mr. Miller is thought to have played a role in the withdrawal of the nomination of Ron Vitiello to lead ICE and the impending departure of Mr. Cissna.

The House speaker, Nancy Pelosi, a Democrat, said of Ms. Nielsen’s departure, “It is deeply alarming that the Trump administration official who put children in cages is reportedly resigning because she is not extreme enough for the White House’s liking.”

The plan is for Ms. Nielsen to continue through Wednesday to help with an “orderly transition.”

“I share the president’s goal of securing the border,” she said Monday morning. “I will continue to support all efforts to address the humanitarian and security crisis on the border.”

If Ms. Nielsen is inclined to perform one last act of public service, she should come clean about the costs of the policies she enforced over the past year and a half, not only to the desperate migrants seeking a better life in the United States, but also to the thousands of employees of her department charged with carrying out an inhumane and ineffective agenda.