WASHINGTON — President Trump told the White House counsel in the spring that he wanted to order the Justice Department to prosecute two of his political adversaries: his 2016 challenger, Hillary Clinton, and the former F.B.I. director James B. Comey, according to two people familiar with the conversation.

The lawyer, Donald F. McGahn II, rebuffed the president, saying that he had no authority to order a prosecution. Mr. McGahn said that while he could request an investigation, that too could prompt accusations of abuse of power. To underscore his point, Mr. McGahn had White House lawyers write a memo for Mr. Trump warning that if he asked law enforcement to investigate his rivals, he could face a range of consequences, including possible impeachment.

The encounter was one of the most blatant examples yet of how Mr. Trump views the typically independent Justice Department as a tool to be wielded against his political enemies. It took on additional significance in recent weeks when Mr. McGahn left the White House and Mr. Trump appointed a relatively inexperienced political loyalist, Matthew G. Whitaker, as the acting attorney general.

It is unclear whether Mr. Trump read Mr. McGahn’s memo or whether he pursued the prosecutions further. But the president has continued to privately discuss the matter, including the possible appointment of a second special counsel to investigate both Mrs. Clinton and Mr. Comey, according to two people who have spoken to Mr. Trump about the issue. He has also repeatedly expressed disappointment in the F.B.I. director, Christopher A. Wray, for failing to more aggressively investigate Mrs. Clinton, calling him weak, one of the people said.