WASHINGTON — For years, President Donald Trump has used Twitter as his go-to public relations weapon, mounting a barrage of attacks on celebrities and then political rivals even after advisers warned he could be creating legal problems for himself.

Those concerns now turn out to be well founded. The special counsel, Robert Mueller, is scrutinizing tweets and negative statements from the president about Attorney General Jeff Sessions and former FBI director James Comey, according to three people briefed on the matter.

Several of the remarks came as Trump was also privately pressuring the men — both key witnesses in the inquiry — about the investigation, and Mueller is examining whether the actions add up to attempts to obstruct the investigation by both intimidating witnesses and pressuring senior law enforcement officials to tamp down the inquiry.

Mueller wants to question the president about the tweets. His interest in them is the latest addition to a range of presidential actions he is investigating as a possible obstruction case: private interactions with Comey, Sessions and other senior administration officials about the Russia inquiry; misleading White House statements; public attacks; and possible pardon offers to potential witnesses.

None of what Mueller has homed in on constitutes obstruction, Trump’s lawyers said. They argued that most of the presidential acts under scrutiny, including the firing of Comey, fall under Trump’s authority as the head of the executive branch and insisted that he should not even have to answer Mueller’s questions about obstruction.

But privately, some of the lawyers have expressed concern that Mueller will stitch together several episodes, encounters and pieces of evidence, like the tweets, to build a case that the president embarked on a broad effort to interfere with the investigation. Prosecutors who lack one slam-dunk piece of evidence in obstruction cases often search for a larger pattern of behavior, legal experts said.

The special counsel’s investigators have told Trump’s lawyers they are examining the tweets under a wide-ranging obstruction-of-justice law beefed up after the Enron accounting scandal, according to the three people. The investigators did not explicitly say they were examining possible witness tampering, but the nature of the questions they want to ask the president, and the fact that they are scrutinizing his actions under a section of the United States Code titled “Tampering With a Witness, Victim, or an Informant,” raised concerns for his lawyers about Trump’s exposure in the investigation.

A spokesman for Mueller’s office declined to comment.

Trump’s lead lawyer in the case, Rudy Giuliani, dismissed Mueller’s interest in the tweets as part of a desperate quest to sink the president.

“If you’re going to obstruct justice, you do it quietly and secretly, not in public,” Giuliani said.

Giuliani was referring to more typical obstruction cases, where prosecutors focus on measures taken in private, like bribing witnesses, destroying evidence or lying under oath. While some of Trump’s private acts are under scrutiny, like asking Comey for loyalty, his public conduct is as well. That sets this investigation apart, even from those of other presidents; Richard M. Nixon and Bill Clinton were accused of privately trying to influence witness testimony.

But as in those cases, federal investigators are seeking to determine whether Trump was trying to use his power to punish anyone who did not go along with his attempts to curtail the investigation.

If Mueller opts to tailor a narrative that the president tried to obstruct the Russia investigation, he would have to clear several hurdles to make a strong case. He would need credible witnesses (Comey and Sessions have been the target of concerted attacks by Trump and allies, undercutting their standing) and evidence that Trump had criminal intent (the special counsel has told the president’s lawyers he needs to question him to determine this).

“There’s rarely evidence that someone sits down and says, ‘I intend to commit a crime,’ so any type of investigation hangs on using additional evidence to build a narrative arc that hangs together,” said Samuel W. Buell, a professor of law at Duke University and former senior federal prosecutor. “That’s why a prosecutor wants more pieces of evidence. You need to lock down the argument.”

It is not clear what Mueller will do if he concludes he has enough evidence to prove that Trump committed a crime. He has told the president’s lawyers that he will follow Nixon- and Clinton-era Justice Department memos that concluded that a sitting president cannot be indicted, Giuliani has said. If Mueller does not plan to make a case in court, a report of his findings could be sent to Congress, leaving it to lawmakers to decide whether to begin impeachment proceedings. Investigators want to ask Trump about the tweets he wrote about Sessions and Comey and why he has continued to publicly criticize Comey and former deputy FBI director Andrew G. McCabe, another witness against the president. They also want to know about a January episode in the Oval Office in which Trump asked the White House counsel, Donald F. McGahn II, about reports that McGahn told investigators about the president’s efforts to fire Mueller himself last year.

Trump has navigated the investigation with a mix of public and private cajoling of witnesses.

Around the time he said publicly last summer that he would have chosen another attorney general had he known Sessions was going to recuse himself from the Russia investigation, Trump tried behind closed doors to persuade Sessions to reverse that decision. The special counsel’s investigators have also learned that Trump wanted Sessions to resign at varying points in May and July 2017 so he could replace him with a loyalist to oversee the Russia investigation.

After Trump tried last July to get Sessions to resign, the president began a three-day public attack on a variety of fronts — tweets, a Rose Garden news conference and a Wall Street Journal interview — criticizing Sessions, raising the specter that he would fire him.

A day later, Trump doubled down, criticizing both Sessions again and McCabe, who was the acting FBI director at the time.

Similarly, Trump’s relationship with Comey was strained from the start by the president’s encroachment on the typically independent Justice Department. In late March 2017, the president asked Comey to put out word that he was not under investigation. Comey demurred, and when the president called about two weeks later to ask again, Comey responded that he had passed along the proposal to the Justice Department, he later testified.

That request having gone nowhere, Trump issued an indirect threat the next day about Comey’s job. “It’s not too late” to ask him to step down as FBI director, he said in an interview with Maria Bartiromo on Fox Business Network. The special counsel wants to ask the president what he meant by that remark.

A few weeks later, in early May, an aide to Sessions sought derogatory information about the FBI director. Sessions, his aide told a Capitol Hill staff member, wanted one negative article a day in the news media about Comey, a person familiar with the meeting has said.

Four days later, Trump fired Comey, citing at first his management of the investigation of Hillary Clinton’s use of a private email server to handle classified information.

By the fall, Comey had become a chief witness against the president in the special counsel investigation, and Trump’s ire toward him was well established. His personal attacks evolved into attacks on Comey’s work, publicly calling on the Justice Department to examine his handling of the Clinton inquiry — and drawing the special counsel’s interest.

Mueller’s deputies told Trump’s lawyers they also wanted to question the president about similar statements at the time by the White House press secretary, Sarah Huckabee Sanders.

“The Department of Justice has to look into any allegations of whether or not something is illegal or not,” Sanders said at a press briefing last September. “That’s not up to me to decide. What I’ve said and what I’m talking about are facts. James Comey — leaking of information, questionable statements under oath, politicizing an investigation — those are real reasons for why he was fired.”

Trump’s lawyers have pushed back against the special counsel about the tweets, saying the president is a politician under 24-hour attack and is within his rights to defend himself using social media or any other means.

The president continues to wield his Twitter account to pummel witnesses and the investigation itself, ignoring any legal concerns or accusations of witness intimidation. This week, he moved to strip the security clearances of six former senior national security officials, including Comey, McCabe and some of his most outspoken critics. And he tweeted false claims about the Russia investigation.