Sanders told CBP employees that he tendered his resignation on Monday and that it will be effective July 5.
"Although I will leave it to you to determine whether I was successful, I can unequivocally say that helping support the amazing men and women of CBP has been the most fulfilling and satisfying opportunity of my career," he said in a statement.
President Trump said Tuesday afternoon that he knew changes were imminent at CBP, but that he did not tell Sanders to step down.
The news comes amid reports about unsanitary conditions at a Border Patrol station in Clint, Texas.
Lawyers who visited facilities where migrant children were being held last week described squalid conditions to The Associated Press, which first reported on the complaints. The conditions at the station in Clint included inadequate food, lack of medical care, and older children trying to care for toddlers.
Many children were moved out of the facility in recent days. But CBP then said officials had moved more than 100 kids back to the station.
Trump said he was "very concerned" about the current conditions of border detention facilities, but claimed they were even worse during President Obama's administration.
The resignation came as House lawmakers were scrambling to pass a $4.5 billion funding bill to combat the escalating humanitarian crisis at the border -- with Republicans accusing Democrats of “playing games” with the crisis, and Democrats urging their GOP counterparts to “show some decency.”
“I’m calling on the speaker not to play politics, to take the Senate bill and that can become law, and that can help humanitarian aid along the border,” House Minority Leader Kevin McCarthy, R-Calif., said at a Republican press conference. “This is not the time to play politics.”
At a separate press conference, Democratic Caucus Chairman Hakeem Jeffries, D-N.Y., pushed for Republicans "to show some decency, show some strength, stop acting like you’re part of a cult and start acting like a separate and co-equal branch of government that has a responsibility to allocate funds in a humane manner."
On Monday night, the White House issued a statement saying it would veto the House bill in its current state, citing the restrictions.
The administration's immigration agencies are currently at the center of numerous controversies, and gripped with turmoil.
Fox News reported Monday that Sanders' predecessor, current acting Homeland Security Secretary Kevin McAleenan, was accused of leaking plans last week for scheduled Immigration and Customs Enforcement raids, after expressing fierce opposition and allegedly ordering top officials to “stand down” on the operation.
President Trump hit pause on those raids over the weekend, holding out for the possibility of a legislative solution.
Fox News' Jake Gibson, Catherine Herridge and The Associated Press contributed to this report.