“It extends,” the court said, “to every offense known to the law.”

In a tweet last month, Mr. Trump indicated that he had studied the matter in the context of the investigation of ties between the Trump campaign and Russia. “All agree the U.S. president has the complete power to pardon,” he wrote.

Mr. Trump could pardon any of the subjects of the special counsel’s Russia inquiry, though some legal specialists believe he could increase his risk of prosecution if he is seen as abusing his pardon power.

Were Mr. Trump to announce that he has pardoned himself, impeachment would remain possible. A prosecutor might also test the limits of the pardon power by indicting Mr. Trump notwithstanding such an announcement. That clash could lead the Supreme Court to weigh in on the limits of the president’s power to spare himself from punishment for criminal wrongdoing.

Most presidents wait for the waning days of their administrations to issue high-profile pardons of associates and supporters. President George Bush was about to leave office in 1992 when he pardoned Caspar W. Weinberger, a former defense secretary, for his role in the Iran-contra affair. President Bill Clinton, too, was almost out the door in 2001 when he pardoned Marc Rich, a fugitive financier whose former wife had donated to the Democratic Party and the Clinton library foundation.

Mr. Trump took a different approach. The Arpaio pardon was the first of his presidency.

P.S. Ruckman Jr., a political scientist and an authority on presidential pardons, said Mr. Trump’s decision to grant clemency to a prominent political ally seven months into his presidency sent the wrong message.

“Hundreds of persons have applied for clemency and have waited for years, some for 10 or 15,” he wrote on the Pardon Power blog. “Imagine how demoralized they must feel now. Now, more gasoline will be poured on the classic misconception that clemency is only for famous persons, rich people, political supporters, insiders, the ‘connected.’”