WASHINGTON – FBI Director James B. Comey told his top agents from around the country that he had been asked by President Donald Trump to stay on the job running the federal government's top law enforcement agency, according to people familiar with the matter.

A decision to retain Comey would spare the president another potentially bruising confirmation battle. It also would keep Comey at the center of the FBI's investigation into several Trump associates and their potential ties with the Russian government.

Retaining Comey could also help calm the bureau's workforce, which has been rattled after a tumultuous few months in which the FBI and the director himself were sharply criticized for moves that many felt influenced the outcome of the presidential election.

During the campaign, Trump harshly criticized the FBI and Justice Department for not bringing criminal charges against Hillary Clinton in connection with her use of a personal e-mail server. After Trump was elected in November, he said in a nationally televised interview that he had not made up his mind about whether he would ask Comey to resign.

When Comey and the president-elect met in Trump Tower for the first time earlier this month for an intelligence briefing, Trump told the FBI director that he hoped he would remain in his position, according to people briefed on the matter. And Trump's aides have made it clear to Comey that the president does not plan to ask him to leave, these people said.

Then, last Wednesday, during a weekly conference call, Comey relayed the news to his senior employees, who are known as special agents in charge.

Under federal law, the FBI director is appointed to a 10-year-term, intended to overlap more than one administration as part of post-Watergate overhauls created to give the director independence and insulate the job from politics. The president can fire the director for cause. Comey, a former senior Justice Department official under President George W. Bush, was appointed by President Barack Obama in 2013.

Those who described the plans for the FBI director spoke on the condition of anonymity because they did not want to be identified discussing confidential conversations between Trump, his aides and Comey.

Representatives for the FBI and White House declined to comment.

Comey will have to manage an increasingly difficult relationship with Trump and his White House, as the FBI is leading an investigation into ties between Trump's associates — including his former campaign manager, Paul Manafort — and the Russian government. As part of that inquiry, agents have examined intercepted communications and financial transactions. Comey has repeatedly declined to discuss the investigation with members of Congress.

Clinton and many Democrats blame Comey for her defeat, and it is not clear whether she would have kept him on had she won.

In July, Comey held a news conference to announce that the bureau was recommending to the Justice Department that Clinton or her aides not be charged in connection with the mishandling of classified information on her personal e-mail server. At the news conference, Comey took the unusual step of criticizing how Clinton and her aides handled classified information, saying it was "extremely careless."

Then, 11 days before the election, Comey sent a letter to Congress saying new e-mails that appeared related to the investigation had surfaced, which the bureau needed to analyze.

The letter set off a flurry of reports about Clinton's personal e-mail server. The e-mails had been found as part of an unrelated investigation into illicit text messages Anthony Weiner — the estranged husband of Clinton's closest aide, Huma Abedin — had sent to a 15-year-old girl in North Carolina. Two days before the election, Comey sent another letter to Congress, saying that the e-mails had not changed the FBI's original recommendation to not charge Clinton.

The Justice Department's inspector general is investigating Comey's handling of the Clinton e-mail case, including both his decision to discuss it at a news conference and to disclose just days before the election that he had new information that could lead him to reopen it.

The FBI says it welcomes the investigation, and FBI officials say they believe more information will be made available to the public that will help explain his actions.

On Sunday at the White House, Trump held an event to honor law enforcement officers who provided security for the inauguration. After calling the Secret Service director to the front of the room, Trump spotted Comey.

"Oh, there's Jim, he's become more famous than me," Trump said.