WASHINGTON — Attorney General Jeff Sessions offered to resign in recent weeks as he told President Trump he needed the freedom to do his job, according to two people who were briefed on the discussion.

The president turned down the offer, but on Tuesday, the White House declined to say whether Mr. Trump still had confidence in his attorney general.

“I have not had that discussion with him,” Sean Spicer, the White House press secretary, told reporters, responding to questions about whether the president had soured on Mr. Sessions.

Mr. Spicer’s remarks came after The New York Times reported that Mr. Trump had vented intermittently about Mr. Sessions since the attorney general recused himself from any Russia-related investigations conducted by the Justice Department. Mr. Trump has fumed to allies and advisers ever since, suggesting that Mr. Sessions’s decision was needless.