Washington (AFP) - Kirstjen Nielsen, the US homeland security chief whose departure was announced by Donald Trump on Sunday, was said to be a frequent target of the president's ire despite being among the staunchest defenders of his controversial immigration policies.

Last summer, as images were broadcast of wailing children being wrested from their parents under the administration's practice of separating families, she took to the White House podium to defend the "zero tolerance" approach, becoming the face of a policy that was decried the world over.

She appeared to have done enough to win over her boss, who until then was reportedly close to firing her for failing to keep an adequate check on illegal border crossings, a cornerstone of Trump's election campaign.

But the reprieve was to prove temporary.

As Border Patrol estimates put the number of migrants passing through Mexico at over 100,000 in March -- nearly a decade high -- an increasingly irate Trump appeared to have lost patience with Nielsen, who had been without her protector John Kelly, the former White House chief of staff, since he resigned last year.

House Speaker Nancy Pelosi summed up the position of many progressive critics, writing: "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."

- Lawyer, cyber-security specialist -

The 46-year-old Nielsen, who would swap elegant office attire for jeans and aviator shades on her frequent visits to the border, kept a low profile when she joined the administration at its outset in January 2017.

A lawyer by training, she had served previously as a cyber security specialist in the Department of Homeland Security (DHS).

She was brought in as assistant to Kelly, a retired marine general who set to work cracking down on illegal immigration as Trump's first DHS secretary.

When Kelly moved to the White House as Trump's top aide in July 2017, Nielsen went with him as his deputy.

Story continues

But by October that year she was back at DHS, this time as secretary.

Described as being all-business, she oversaw a sprawling department with 200,000 employees and wide-ranging responsibilities.

Disaster relief, cyber security, transportation security, the Coast Guard, customs and policing the borders all fall under the department's purview.

So it fell to her to carry out Trump's most fiercely held objective: stopping illegal immigration.

It was a daunting, deeply controversial task in a country with an estimated 11 million people living without papers, many with families and deep roots in their communities.

Under Trump, Nielsen's department embarked on sweeping roundups and tough new measures, including barrier construction on the Mexico border.

- Loyalist -

She will be remembered most, however, as the primary defender of the Trump administration's most widely condemned practice -- since revoked -- of separating migrant children from their parents as part of a policy of prosecuting all illegal border crossers.

Nielsen faced down opposition calls to resign as condemnation pours in from the United Nations, human rights groups, and four former first ladies -- all mothers -- who have called the policy "cruel" and "immoral."

She would go on to counter-attack, bristling at suggestions that the children were being mistreated, or placed into what appeared to be "cages."

Instead, toeing the administration's line, she blamed Congress for passing laws that offer illegal immigrants numerous "loopholes."

And in any case, the children taken from their parents after crossing the border were "well taken care of," she said.

Nielsen's relationship with Trump was long said to be tenuous. But despite reports he complained constantly about her performance, she continued to loyally defend him.

When participants in a White House session on immigration quoted Trump as referring to African nations as "shithole" countries, Nielsen came to the president's defense.

"I did not hear that word used," she told a congressional hearing.

Quizzed about Trump's statement that he would prefer immigrants from a country like Norway, Nielsen spun it as Trump's appreciation of the skills of Norwegian workers, and not their race.

"Norway is a predominantly white country, isn't it?" a senator asked her.

"I actually do not know that, sir, but I imagine that is the case," replied Nielsen -- herself of Scandinavian lineage.

That loyalty persisted until the end: last month, she defended the president's declaration of a national emergency to secure funding for his pet project, a wall on the US-Mexico border.

And her letter of resignation left little doubt Nielsen remained a true believer in Trump's crusade against undocumented migrants.

"I hope that the next Secretary will have the support of Congress and the courts in fixing the laws which have impeded our ability to fully secure America's borders and which have contributed to discord in our nation's discourse," she wrote.