Mr. Trump should not talk to investigators about his actions as president, even under a subpoena, Mr. Barr wrote in his 19-page memo, which became public during his confirmation. Mr. Barr based his advice on a sweeping theory of executive power under which obstruction of justice laws do not apply to presidents, even if they misuse their authority over the Justice Department to block investigations into themselves or their associates for corrupt reasons.

But Mr. Barr tempered his theory with a reassurance. Even without the possibility of criminal penalties, he wrote, a check is in place on presidents who abuse their discretionary power to control the executive branch of government — impeachment.

The fact that the president “is answerable for any abuses of discretion and is ultimately subject to the judgment of Congress through the impeachment process means that the president is not the judge in his own cause,” he wrote.

He added, “The remedy of impeachment demonstrates that the president remains accountable under law for his misdeeds in office,” quoting from a 1982 Supreme Court case.