The White House is also pressing for the resignation of Claire Grady, the acting deputy secretary, who under law would normally fill in for Ms. Nielsen. Mr. Trump has already announced that he will install Kevin K. McAleenan, the Customs and Border Protection commissioner, as Ms. Nielsen’s acting replacement, which he cannot do if Ms. Grady remains in place.

The latest moves appeared to be a housecleaning of officials associated with John F. Kelly, the president’s former chief of staff and his first homeland security secretary, who was pushed out at the end of last year after months of tension with Mr. Trump.

Mr. Alles, a retired Marine major general who served with Mr. Kelly in the military and goes by Tex, was the first person from outside the Secret Service to head the agency in more than a century and some administration officials said he had a hard time fitting in.

At Mr. Trump’s instruction, Mick Mulvaney, the acting White House chief of staff, told Mr. Alles at least 10 days ago to expect a transition after two years in office and to develop an exit plan, according to officials familiar with the discussions.

Mr. Trump, who talks with members of his own Secret Service detail, had soured on Mr. Alles a while ago, convinced that as an outsider he was not popular among the agents, officials said. The president even made fun of the director’s looks, calling him Dumbo because of his ears. But a Secret Service ally of Mr. Alles disputed the notion that he did not fit in, saying that the director was well liked among the work force.

Mr. Alles was told to develop an exit plan before the arrest of a Chinese woman carrying a malware-laced device at Mar-a-Lago, exposing holes in the security of the private club. The Secret Service was so disturbed that it issued a statement faulting the club’s staff for not tracking its guests closely enough.