Homeland Security Secretary Kirstjen Nielsen resigned from her position on Sunday evening, after serving 16 turbulent months as the nation’s top national security official and the president's punching bag on border security.

Nielsen’s immediate departure comes only two days after President Donald Trump announced that he was withdrawing the nomination of Ronald D. Vitiello to head U.S. Immigration and Customs Enforcement, the Homeland Security agency tasked with enforcing Trump’s border policy, in favor of a “tougher” nominee who has yet to be named.

Trump lambasted the current enforcement of American immigration laws for years, and as the nation’s top immigration and national security official, those laws and their implementation fell under Nielsen’s purview.

In a tweet, President Trump said Nielsen “will be leaving her position,” and announced that Kevin McAleenan, the current U.S. Customs and Border Protection Commissioner, will become acting secretary as he searches for a permanent replacement.

In her resignation letter, Nielsen appeared to lay partial blame on Congress for failing to provide the Department of Homeland Security with “all the tools and resources... to execute the mission.”

“I hope that the next Secretary will have the support of Congress and the courts in fixing the laws which have impended our ability to fully secure America’s borders and which have contributed to discord in our nation’s discourse,” Nielsen wrote.

Nielsen’s ouster comes amid a continuing—even continuous—shakeup in the Trump administration. The president cleaned house after the midterm elections, ditching former Attorney General Jeff Sessions and other officials he viewed as disloyal or unwilling to cooperate on strategy.

Officials inside the Department of Homeland Security told The Daily Beast that they have speculated Nielsen would be out of a job sometime after the midterms. Nielsen, Trump and National Security Adviser John Bolton have often quarreled about the department’s strategy on immigration, officials said, and Nielsen is regularly chastised for not taking a tough enough stance on border security.

One former department official told The Daily Beast that Trump’s decision to replace Nielsen with the head of U.S. Customs and Border Protection was indicative of the president’s superficial understanding of immigration and national security policy.

“Just because there’s a new man at the helm of DHS, the border crisis will be fixed?! Ha!” the official said in a text. “They think just because he’s former CBP, and he understands the border, he’ll fix it? I don’t think so.”

Plus, the official added, “getting a man is so stereotypical!”

Nielsen was one of three women in Trump’s cabinet.

Internally, staffers and officials said Nielsen was viewed by some as too loyal to the president, often catering to his demands despite the legal implications. Officials said Nielsen’s public rhetoric on immigration and asylum is crafted specifically to cater to President Trump.

The general focus of the department has changed drastically under Nielsen’s leadership, too, officials said. Over the past year, most of the department’s high-level briefings and meetings have centered around threats by foreign actors, particularly those from South America. At the same time, the department has drawn back from looking at threats posed by people living in the U.S. who have the potential to carry out mass casualty attacks, the officials said.

Even after shootings in Pittsburgh and California, the department continued to focus more of its attention on border security and migrant caravans, DHS staffers told The Daily Beast.

In news briefings compiled for the secretary and her senior staff over a three-week period obtained by The Daily Beast, the secretary was shown to have overwhelmingly received news updates on migrant caravans and Trump’s remarks on immigration enforcement, despite two mass shootings and security concerns about midterm elections at the time.

The top of the press packet compiled and distributed on November 9, 2018, the day after the shooting in Thousand Oaks, reads: “Administration Moves To Require Asylum Seekers To Go To Designated Ports Of Entry.” Under that section, the briefing quotes and bolds a Breitbart headline: “Fewer than 10 percent of Central American Migrants Arriving At Border Have Legitimate Asylum Claim.”

Out of about 19 pages of quoted media text, one and a half focused on the California shooting, three and a half on border security and immigration and six on the Mueller investigation. The rest of the pages touched on news about cybersecurity, terrorism investigations and other DHS-related topics.

Despite that near-myopic focus on immigration, the president has reportedly been frustrated with Nielsen’s enforcement of some of his more controversial border policies for some time, most notably the chaotic implementation and eventual reversal of its family separation policy in late spring. At the time, Nielsen told reporters that the policy didn’t even exist—“period”—even as the government held hundreds of undocumented minor children who had forcibly been taken from their parents.

Nielsen was reportedly berated by President Trump in a Cabinet meeting in May 2018 over his perception that she was not doing enough to keep the southern border secure. The verbal flogging, detailed by The New York Times, prompted Nielsen to draft a resignation letter which she ultimately decided not to deliver.

Both the Department of Homeland Security and Nielsen herself denied she planned to step aside at the time.

For months, Nielsen soldiered on, testifying to the Senate Homeland Security and Governmental Affairs Committee, where she defended the administration's new, controversial policy of separating children from their parents if they cross the border illegally, even if they are claiming asylum. Trump, according to the Times report, had suspected Nielsen along was privately resisting his order to implement this policy as a deterrent.

“Our policy is if you break the law, we will prosecute you,” Nielsen said. “You have an option to go to a port of entry and not illegally cross into our country.”

As she left the hearing, she answered a reporter’s question as to her future.

“I have not resigned, I didn’t threaten to resign,” she said, according to Politico.

Nielsen, a cybersecurity expert who previously worked in the George W. Bush administration, is a protégée of Gen. John F. Kelly, whom she replaced at the top of Homeland Security in early December.