Department of Homeland Security Secretary Kirstjen Nielsen has resigned, President Trump tweeted Sunday.

"Secretary of Homeland Security Kirstjen Nielsen will be leaving her position, and I would like to thank her for her service. I am pleased to announce that Kevin McAleenan, the current U.S. Customs and Border Protection Commissioner, will become Acting Secretary for @DHSgov. I have confidence that Kevin will do a great job!"

Behind the scenes: A source close to DHS told Axios that Nielsen would be having a showdown with the president on Sunday night.

"Frustrations were building on both sides," the source said. "She was undercut at every turn. She's done everything she can do. The White House is eating their own."

CBS' Paula Reid reported earlier Sunday that Nielsen was "expected to resign" in her meeting with Trump that night, but Trump's ambiguous wording reflects the predictably messy end to this relationship, which was formalized in a meeting in the White House residence.

It may well be that Nielsen was the one who formally resigned — but the formalities don't really matter. Trump has wanted Nielsen gone for months because he believes she's "weak" on immigration, per multiple sources with direct knowledge of the president's thinking.

The big picture: It's been a tortured relationship from the beginning, with Trump blaming Nielsen for every problem at the southern border and for the recent spike in families coming from Northern Triangle countries. Trump has long felt that Nielsen isn't "tough enough" when it comes to defending the border and kicking illegal immigrants out of the U.S., according to sources who've discussed the subject with the president.

During her tenure, Nielsen was put in the position of having to defend the Trump administration's zero tolerance policy that resulted in thousands of migrant children being separated from their families, for which she was often maligned in the media and by Democratic lawmakers.

In January, Sen. Jeff Merkley (D-Ore.) formally requested that the FBI investigate whether Nielsen lied under oath when she told Congress in December 2018, "We've never had a policy for family separation."

The latest: Nielsen said in a tweet Sunday night she had agreed to stay on as homeland security secretary until Wednesday "to assist with an orderly transition and ensure that key DHS missions are not impacted."

Go deeper: