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. On Tuesday, the White House declined to say whether Mr. Trump still has confidence in his attorney general.

“I have not had that discussion with him,” Sean Spicer, the White House press secretary, told reporters in the White House briefing room, responding to questions about whether the president has 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 Department of Justice. Mr. Trump has fumed to allies and advisers ever since, suggesting that Mr. Sessions made a needless decision.

He has also blamed Mr. Sessions for the fallout from an executive order that the president signed putting in place a travel ban on seven primarily Muslim countries, which courts have blocked.

The situation between Mr. Sessions and Mr. Trump has grown so tense that the attorney general told Mr. Trump in recent weeks that he needed the freedom to do his job and that he could resign if that was what was wanted, according to the two people who spoke on the condition of anonymity to discuss internal White House matters. Mr. Trump did not take him up on the offer.

A spokesman for Mr. Sessions declined to comment. A White House spokeswoman did not respond to an email seeking comment.

The frustration at times goes both ways. Mr. Sessions was upset when the president appointed a task force to tackle the opioids crisis in March and tapped Gov. Chris Christie of New Jersey to lead it without consulting the attorney general first, according to an administration official who asked not to be named discussing internal matters.

The offer by Mr. Sessions to discuss resigning, however lightly he made it, was a surprising move from one of the president’s earliest and most vocal supporters. Mr. Sessions was an early endorser of Mr. Trump’s candidacy, and his former spokesman, Stephen Miller, is now Mr. Trump’s main speechwriter and a policy adviser.