A handful of senior F.B.I. employees have been told to resign in a matter of days or be fired, as the Trump administration moves to shake up the agency’s upper ranks, according to people familiar with the discussions.

The steps came as Kash Patel, the president’s nominee to lead the agency, sought to assure lawmakers during a contentious, hourslong Senate confirmation hearing that he would not begin a campaign of retribution or look backward by pursuing perceived rivals. It is unclear whether he was informed of the decisions, which were disclosed on the condition of anonymity to describe personnel matters.

The employees given the apparent ultimatum had been promoted under Christopher A. Wray, who stepped down as F.B.I. director this month.

In an email to colleagues, one of the senior agents said he had learned he would be dismissed “from the rolls of the F.B.I.” as soon as Monday morning.

“I was given no rationale for this decision, which, as you might imagine, has come as a shock,” he wrote.

Senior F.B.I. agents had been bracing for potentially swift changes under President Trump given Mr. Patel’s past promise to reshape the institution. He has vowed to empty out the F.B.I. headquarters building and turn it into a museum.

The move is remarkable in part because it is happening before a director has been confirmed to take charge of the bureau, and the quick and unexpected nature of the requests has left employees badly shaken.

F.B.I. directors have more latitude than most agency chiefs in whom they place into senior positions, but they typically do so gradually. Until senators vote on Mr. Patel’s nomination, Brian Driscoll is the bureau’s acting director.

The decision by the Trump administration echoes the moves rapidly underway at the Justice Department, where career prosecutors, including top officials who hold significant sway over how the agency makes charging decisions, have been reassigned or fired.

At the F.B.I., some of the senior officials who have been asked to leave are at headquarters while others work in the field. Some have already taken steps to retire and exit the agency, including an agent who worked on the F.B.I.’s investigation into Russian interference in the 2016 election, and another who oversaw an investigation into Mr. Trump’s handling of classified documents.

A person familiar with the personnel changes said the top agent at the Washington field office, the second-largest in the bureau, was also given an ultimatum on Thursday. He had planned to retire, though intended to stay longer at the bureau to help with the transition. But his plans were cut short.

Still more are worried they will be pushed out of the agency or demoted.

During Mr. Patel’s confirmation hearing, Senator Cory Booker raised the abrupt dismissals of nearly a dozen career prosecutors at the Justice Department who worked on the criminal investigations into Mr. Trump under the special counsel Jack Smith and whether similar moves would extend to the F.B.I.

“Are you aware of any plans or discussions to punish in any way, including termination, F.B.I. agents or personnel associated with Trump investigations?” asked Mr. Booker, Democrat of New Jersey, after reminding Mr. Patel that he was under oath.

Stating that he had not been involved in the decisions at the Justice Department, Mr. Patel replied, “I am not aware of that, Senator.”

CNN earlier reported that FB.I. officials had been demoted or resigned.