(CNN) Department of Homeland Security Secretary Kirstjen Nielsen left Washington last Sunday for what was supposed to be a week-long trip to Europe. While there, Nielsen planned to discuss cybersecurity and terror threats with senior UK and Swedish government officials, and attend a meeting of G7 interior ministers in Paris -- providing her a temporary respite from the tense situation at the US Southern border, where a recent rise in migrant apprehensions had drawn the intense ire of President Donald Trump.

Instead, the trip proved to be a miscalculation on her part, one that began a week-long descent into limbo for Nielsen that ended with her abrupt resignation on Sunday evening after meeting with Trump in the White House. Nielsen did not resign willingly, a person close to her told CNN, but was under pressure to do so. Nor did she fight or plead to keep her job, the source said.

The resignation ends months of speculation over her possible departure.

It also demonstrates the power of immigration hardliners inside the White House, including national security adviser John Bolton and senior adviser Stephen Miller, who, despite her defense of the administration's controversial policies, still deemed Nielsen insufficiently tough when it came to stemming the flow of migrants to the border.

According to multiple administration officials, over the past few months it had become clear to many inside the White House that Nielsen had few allies left in the West Wing, particularly following last year's departure of chief of staff John Kelly, widely seen as her biggest advocate in the White House.

Nielsen butted heads with Kelly's replacement Mick Mulvaney. Miller openly complained about her to the President. She was also a target of Bolton's, according to four people familiar with their relationship. Bolton often criticized Nielsen for how she was handling immigration issues and had no hesitation about expressing his reservations openly in front of President Trump.

Nielsen had no ally in the President's son-in-law Jared Kushner either, who has become more involved in immigration talks recently, according to one administration official. In a sense, Nielsen had become an island unto herself inside the West Wing, and the people who talk to Trump the most were openly against her.

By early Sunday, Nielsen knew how the day would likely go and that she would likely be forced to resign, according to a source familiar with her thinking.

Shortened Trip

In the weeks leading up to her Europe trip, Nielsen had been increasingly on thin ice in the eyes of the President. She apparently did not realize how tenuous her standing was when she left for Europe, but once there quickly realized her mistake and abruptly returned after her first day of meetings in London. Nielsen hastily left to travel to the US southern border, where she visited three border regions, ending at a stop in Calexico, California, to join the President.

During the week, Nielsen did interviews -- including on CNN -- to try and improve the President's souring view of her, a source close to Nielsen said, but to little avail. Last week, she also convened an emergency call with members of Trump's Cabinet to discuss migration at the border.

"We are going to treat it as if we have been hit by a Cat 5 hurricane," Nielsen said on the call, a participant told CNN.

The call took White House officials by surprise, according to a person familiar with the matter. Neither Miller nor Trump cared for Nielsen's decision to treat the situation at the border as a hurricane, the person said. "People were caught off guard" by the Thursday call, they added. It appears Miller did not know what Nielsen was up to, a major problem according to this person.

At the end of the day, the source said, Nielsen could not make Trump happy with her performance on the border. This source said Trump might as well name Miller as the next DHS secretary. "He's the one driving the policy," the source added.

Miller was also behind the sudden withdrawal of the nomination of Ron Vitiello for director of Immigration and Customs Enforcement, which caught both Congress and the Department of Homeland Security by surprise. Nielsen was unaware what was happening until after the nomination was pulled, a person familiar with the news said.

Nielsen's resignation also follows plans to cut aid to some Central American countries, marking a sudden reversal after Nielsen had, days earlier, visited Honduras to sign a regional compact agreement with Honduras, El Salvador and Guatemala.

Tenuous relationship

Trump hired Nielsen as DHS secretary, based on a strong recommendation from his former chief of staff John Kelly, but the President was rarely happy with her, a source told CNN.

Despite Trump's displeasure, she remained in place thanks to Kelly's ability to divert some of Trump's anger over immigration away from her and onto others, like former Attorney General Jeff Sessions, according to one source. There was also no clear replacement lined up in the event of Nielsen's departure.

A key moment came in May 2018, when Trump and Nielsen got into a lengthy, heated argument during a Cabinet meeting focused on immigration.

Trump was furious with Nielsen, telling her he didn't think she was doing enough to secure the border. But Nielsen stood her ground, citing the law in certain instances, the source said.

Nielsen increasingly pushed back when the President lashed out at her department for not doing more to stem the tide of undocumented immigrants.

A senior administration official said that in recent days Trump and Nielsen had again clashed over the issue. He accused her of not doing her job, and she responded forcefully.

Around the midterm elections in November, it was expected that Trump would ask Nielsen to resign. After the departure of Kelly as White House chief of staff, speculation increased that she would soon be following him out the door.

But by last December, sources told CNN that Trump had warmed to Nielsen, at least temporarily easing the tension in an explosive relationship that was once seen as untenable.

Trump soon began praising her repeatedly behind closed doors, which surprised officials who were used to hearing his frequent criticism of her.

"People overplayed this idea that Gen. Kelly was her protector and that after she left the White House, she would leave," said a former DHS official.

"The very active and leading role that she took on immigration, re-established her with the President in ways that maybe when General Kelly was still there wasn't possible," added the former DHS official.

But it wasn't enough to mend their relationship. And over the past three months, the surge of migrants continued to rise despite a slew of aggressive immigration policies.

Child Separations

Under Nielsen's leadership, thousands of families along the southern border were separated, sparking an uproar across the country last year.

Though it was the result of a policy implemented last year by Sessions, Nielsen was often cast as the face of family separations, and endured withering criticism as a result. While frustrated, one of the reasons Nielsen decided to stick it out was to repair her image, a source familiar with her thinking told CNN.

Still, that policy and others that make it harder for migrants to claim asylum appear to have done little to deter migrants from journeying to the US-Mexico border. Customs and Border Protection Commissioner Kevin McAleenan, who is taking over DHS in an acting capacity, warned late last month that the US was on pace to encounter more than 100,000 migrants in March alone, making it "the highest month since 2008."

Relief and exasperation

A source familiar with Nielsen's thinking told CNN Nielsen is taking this as a relief. Nielsen "believed the situation was becoming untenable" with Trump "becoming increasingly unhinged about the border crisis and making unreasonable and even impossible requests," a senior administration official told CNN on Sunday.

In California on Friday, a senior administration official tells CNN, Trump told border agents he wanted them to stop letting people cross the border, despite the fact that Central American asylum seekers according to US law can do so.

It's unclear what Trump will look for in a permanent successor. For now, he has named McAleenan, the current CBP Commissioner, as acting secretary.

Nielsen leaves behind a bare bones department that not only oversees immigration issues but also cybersecurity, infrastructure protection, the Transportation Security Administration and the Federal Emergency Management Agency.

"We had a Secretary who knew cyber, knew FEMA, knew immigration," said an administration official. "Now you'll get someone who knows border and immigration, but may not know the rest of DHS."

"Secretary [Nielsen] worked harder than any cabinet person I know of, but probably had the most difficult job," the official added.

Asked about the mood at DHS following Nielsen's resignation, one DHS official told CNN there was, "some exasperation," adding that the department doesn't "have enough depth" to fill longtime vacancies.

"We are losing leadership faster than we can get it confirmed or even hired permanently," the official said, noting the number of acting officials in place heading units inside the department. DHS has had at least three positions filled by people in an acting capacity in senior roles.

"Now this is going to cause a massive move up the chain everywhere and it's rare an acting executive permanently selects anyone for those jobs so we'll be without permanent leaders that much longer."