In an interview last week, Sanders blamed the problems in detention on a lack of money. He called on Congress to pass a $US4.5 billion emergency funding bill to address the crisis - legislation the House was planning to take up Tuesday.
At the White House Trump said he did not ask Sanders to resign, adding that he doesn't think he has ever spoken to the man. The president defended US border authorities, saying: "The laws are so bad and the asylum rules and laws are so bad that our Border Patrol people, who are so incredible, aren't allowed to do their jobs."
The unprecedented surge of migrant families has left US immigration detention centres severely overcrowded and taxed the government's ability to provide medical care and other attention.
The Trump administration has faced a barrage of criticism in recent days over conditions inside the Border Patrol facility in Clint, Texas, first reported by The Associated Press: inadequate food, lack of medical care, and older children trying to care for toddlers.
In one case reported in Clint, attorneys said a 2-year-old boy without a diaper was being watched by older children. Several youngsters had the flu. Many were separated from extended family members like aunts and uncles who brought them to the border; others were teenage mothers with babies.
Loading
An official from Customs and Border Protection said Tuesday that the majority of the roughly 300 children detained at Clint last week had been moved to facilities operated by the Office of Refugee Resettlement. The official, who briefed reporters on the condition of anonymity, wouldn't say exactly how many.
But around the same time Sanders announced his resignation, his agency said officials had moved more than 100 children back to the station.
Previously CBP's chief operating officer, Sanders was named acting commissioner in April after the agency's previous leader, Kevin McAleenan, became acting secretary of the Department of Homeland Security. Other key DHS agencies also have interim or acting directors, including US Immigration and Customs Enforcement and US Citizenship and Immigration Services.
ICE on Saturday delayed a long-planned operation to sweep US cities and arrest hundreds of people accused of flouting orders to leave the country, days after Trump's tweets about the operation alarmed immigrant families and advocates. Former ICE acting director Thomas Homan, a Trump administration ally, then went on television to accuse McAleenan of leaking information about the operation because he opposed it.
CBP is the agency that apprehends and first detains migrant parents and children crossing the Mexican border.
CBP's facilities at the Mexican border were almost all built when most people crossing the border illegally were single adults. Now, the agency is apprehending tens of thousands of parents and children weekly. It recorded 84,500 apprehensions of adults and children travelling together in May.
Six children have died since last year after being detained by border agents. At least two are believed to have died of complications of the flu, including a 16-year-old who was left to sleep on a concrete bench inside a Border Patrol station.
"The death of a child is always a terrible thing, but here is a situation where, because there is not enough funding ... they can't move the people out of our custody," Sanders said.
In the wake of Sanders' resignation, Democratic Representative Bennie G. Thompson of Mississippi, chairman of the House Homeland Security Committee, lashed out at the administration's immigration policies and "bad actors in the White House."
"There is simply no excuse for the horrific conditions children and families are being held in at the border," he said.
Jennifer Quigley, director of refugee advocacy for Human Rights First, called on Congress to provide money for caring for migrant children and to hold oversight hearings on the treatment of youngsters in detention.
"Trump administration officials need to be held accountable for the disgraceful response to the situation at the border," she said in a statement. "This is only the tip of the iceberg. We need a full accounting of how children came to be caged in filthy and unsafe conditions.