Mark Morgan, who has led the United States Border Patrol for just a few months, will leave the agency just days after President Trump announced plans to increase the number of agents, according to a statement Thursday from Customs and Border Protection, which oversees the agency.

Mr. Morgan told senior Border Patrol officials that he had been asked to resign, said one official, who spoke on the condition of anonymity because the official was not authorized to speak to the news media. The official described staff members as shocked.

Mr. Morgan’s last day at the agency, which has more than 20,000 agents and is responsible for border security, is Tuesday. He could not be reached for comment.

Mr. Morgan had expressed a desire to stay at the agency in the Trump administration, a Department of Homeland Security official said.