His comment to the sailors appeared to be ad-libbed, but still troubled security experts. “It was a mistake for the president to make this comment,” said Peter D. Feaver, a specialist on civilian-military matters at Duke University and a former national security aide to Mr. Bush. “While there is a legitimate role for senior brass to explain military affairs to the public, it is not good for civil-military relations to have the military viewed as a special interest group pleading for bigger budgets.”

During last year’s campaign, Mr. Trump said that if he won, he would have Mrs. Clinton prosecuted. “Lock her up,” supporters chanted in what became a campaign mantra. Since taking office, however, he has said that would not be productive.

By Monday, he had returned to his campaign view. “So why aren’t the Committees and investigators, and of course our beleaguered A.G., looking into Crooked Hillarys crimes & Russia relations,” he wrote, omitting an apostrophe.

Few took that to be an actual order to the Justice Department. In reality, it seemed like more of a political point, diverting attention while arguing that his opponent was the one who was really corrupt and he was being treated to a double standard. But with Mr. Trump, nothing is certain, and his staff did not disavow the possibility.

“I think that he would hope that the Department of Justice would look into any potential area where the law could have been broken,” Sarah Huckabee Sanders, the newly promoted White House press secretary, told reporters on Air Force One en route here. “If there’s the possibility of that, they should take a look.”

Democrats denounced what they called banana republic politics while Republicans warned that Mr. Trump was venturing into dangerous territory. “Presidents don’t order the prosecution of their defeated opponents in this country,” said Ari Fleischer, a former White House press secretary under Mr. Bush. “It’s never sat well with me. That leads to a divided America.” He added that Mr. Trump “does it to fire up the pro-Trump base of the party.”

Mr. Trump’s defenders said that while his statement might be unusual, no other major presidential candidate campaigned while under investigation by the F.B.I., as Mrs. Clinton was. But Mrs. Clinton was cleared of criminal wrongdoing by the F.B.I. in the case of her private email server.