WASHINGTON — Shortly after learning in May that a special counsel had been appointed to investigate links between his campaign associates and Russia, President Trump berated Attorney General Jeff Sessions in an Oval Office meeting and said he should resign, according to current and former administration officials and others briefed on the matter.

The president attributed the appointment of the special counsel, Robert S. Mueller III, to Mr. Sessions’s decision to recuse himself from the Justice Department’s Russia investigation — a move Mr. Trump believes was the moment his administration effectively lost control over the inquiry. Accusing Mr. Sessions of “disloyalty,” Mr. Trump unleashed a string of insults on his attorney general.

Ashen and emotional, Mr. Sessions told the president he would quit and sent a resignation letter to the White House, according to four people who were told details of the meeting. Mr. Sessions would later tell associates that the demeaning way the president addressed him was the most humiliating experience in decades of public life.

The Oval Office meeting, details of which have not previously been reported, shows the intensity of Mr. Trump’s emotions as the Russia investigation gained steam and how he appeared to immediately see Mr. Mueller’s appointment as a looming problem for his administration. It also illustrates the depth of antipathy Mr. Trump has had for Mr. Sessions — one of his earliest campaign supporters — and how the president interprets “disloyalty” within his circle of advisers.