For nearly two years, the public, Congress and the White House waited to learn if special counsel Robert S. Mueller III would find that President Trump had committed crimes. When the answer was finally revealed, it turned out Mueller didn’t think that was his job at all.

The special counsel ended his investigation last month, pointedly choosing not to reach a conclusion about whether the president had obstructed justice.

In a report of its findings, Mueller’s team said that choice was driven in large part by a long-standing legal opinion at the Justice Department’s Office of Legal Counsel (OLC) that a sitting president should not be indicted, even if the charges remained sealed.

Mueller's team concluded that also meant they could not accuse the president of a crime, even in secret internal documents, the report said.

That move surprised everyone, including Attorney General William P. Barr and his senior advisers, according to current and former Justice Department officials. When Mueller presented his findings without reaching a decision about the president, Barr reviewed the evidence and decided that Trump had not obstructed justice.

The unusual ending to the investigation stems from a key legal disagreement between Mueller’s team and Barr — opening the door to further political fights over presidential power, Justice Department policies and decision-making inside the Trump administration.

Jonathan Turley, a law professor at George Washington University, said Mueller’s choice not to make a decision on obstruction was “one of the biggest surprises of the report,” and he was still struggling to understand the special counsel’s thought process.

“It doesn’t make any sense, because on collusion, he seemed to be perfectly empowered to reach a conclusion on whether the president committed a crime,” Turley said. “The other problem is that his mandate clearly allowed him to make a decision, and [Justice Department headquarters] had clearly indicated he could make a decision.”

Spokesmen for the Justice Department and the special counsel’s office declined to comment.

The redacted Mueller report released Thursday makes clear that he and his prosecutors viewed the OLC opinion to mean they also could not come to a conclusion about whether the president had committed a crime because it would violate Justice Department standards of fairness to make such an accusation — even secretly — without giving the person a chance to fight the accusation.

Barr disagreed.

In releasing the report Thursday, the attorney general told reporters that Justice Department officials asked Mueller “about the OLC opinion and whether or not he was taking the position that he would have found a crime but for the existence of the OLC opinion.”

“He made it very clear, several times, that he was not taking a position — he was not saying but for the OLC opinion he would have found a crime,” Barr said.

Mueller’s approach to the question of whether the president tried to obstruct justice has created tension inside the Justice Department, according to current and former officials. Privately, some senior officials at the Justice Department have been unhappy that Mueller did not reach a conclusion about whether Trump’s conduct rose to the level of a crime, said the officials, who like others spoke on the condition of anonymity because of ongoing sensitivity surrounding the probe.

Barr, according to officials, first learned at a meeting with Mueller on March 5 that the special counsel would not make a decision about whether the president had committed a crime. Deputy Attorney General Rod J. Rosenstein, who tapped Mueller to take the job nearly two years ago and has overseen it since, has told others that he, too, was surprised by Mueller’s comments in early March, according to people familiar with the discussions.

The Mueller report suggests that the OLC opinion weighed heavily on his team’s thinking, and said the special counsel’s office “conducted a thorough investigation in order to preserve the evidence when memories were fresh and documentary materials were available,” suggesting that perhaps another prosecutor could file a charge against Trump after he leaves office.

At other points the report implies — but never says outright — that Congress should assume the role of making prosecutorial decisions when it comes to the president.

“The conclusion that Congress may apply the obstruction laws to the President’s corrupt exercise of the powers of office accords with our constitutional system of checks and balances and the principle that no person is above the law,” Mueller’s team wrote.

Legal analysts said they were hopeful Mueller would clarify why he left open the question of whether he believed Trump obstructed justice — perhaps during congressional testimony next month.

Barr was attorney general in the George H.W. Bush administration, when Mueller headed the Justice Department’s criminal division, and Barr has said he considers the special counsel a friend. It is unclear to what extent, if any, they have discussed recent events. Barr said at his news conference that he had not spoken with Mueller directly about the decision that Trump did not obstruct justice, but he understood it was his “prerogative” to make the call.

Mueller, Barr said Thursday, “did not indicate that his purpose was to leave the decision to Congress,” and added: “I hope that was not his view, since we don’t convene grand juries and conduct criminal investigations for that purpose.”

Analysts noted that lawmakers, in effect, gave Barr authority over Mueller when they let the independent counsel law expire in 1999. That law created a prosecutor position with even more autonomy than Mueller, who was appointed under more restrictive special counsel regulations.

“There has to be a final decision-maker. And this is not an independent counsel case, which means it is the attorney general,” said Jacob Frenkel, a white-collar defense attorney who used to work in the independent counsel’s office. “If Congress does not like the decision, because it was made by the attorney general, Congress only has itself to blame for not renewing the independent counsel statute.”

Former independent counsel Robert W. Ray said that Mueller might have felt hamstrung because he was weighing not only factual and legal concerns, but also Justice Department policy. Policy concerns, Ray said, are generally in the purview of the attorney general, and Mueller might have felt he couldn’t by himself work around the OLC opinion barring such a criminal charge.

“He doesn’t set department policy. He has no say in that,” Ray said. “You got to be careful about playing God here. That’s one of the things about being independent counsel and investigating presidents. All you can do is your job.”

But Ray said he suspected another reason for Mueller’s punt: He did not want to put Barr in a position of having to overrule him.

“I do think it’s a component of the special counsel’s thinking that if he had gone that direction, he was well aware of the fact that the Department of Justice’s view would be and the attorney general’s decision would be to overrule it, and that is not a desirable place for the country to be,” Ray said. “I’m sure the attorney general didn’t appreciate the fact that he was put in the position of having to resolve the matter either, but given those two choices, I think it was better to have left it unresolved and have the attorney general take it from there.”

Ray said he was sympathetic to Barr’s predicament: “My view is that if I had been in that position, and I were the attorney general, I step in and I resolve it, because that’s your job.”

After reviewing Mueller’s report privately last month, Barr announced that he and Rosenstein had concluded that the president did not violate the law. Some members of the special counsel team have been frustrated by Barr’s characterizations of their work, these officials said.

On Thursday, Barr publicly acknowledged some disagreements with Mueller, the former FBI director brought back into government service at a time of crisis nearly two years ago to investigate the president.

Barr said Thursday that he and Rosenstein “disagreed with some of the special counsel’s legal theories and felt that some of the episodes did not amount to obstruction as a matter of law” but that they accepted the special counsel’s “legal framework” as they analyzed the case.

And in a letter to Congress the same day, Barr emphasized what he views as the core role of a prosecutor — to reach a conclusion about criminal conduct.

“The Attorney General has ultimate responsibility for all criminal investigations conducted by the Department. The very function of a federal prosecutor conducting a criminal investigation is to determine whether an offense has been committed, and if so, whether there is sufficient evidence to overcome the presumption of innocence that attaches to every person,” Barr wrote.

That wasn’t the only disagreement between the attorney general and the special counsel — Mueller’s report features a lengthy pushback against a legal theory of obstruction advocated by Barr.

As a lawyer in private practice last year, Barr wrote a scathing memo critical of what he viewed as Mueller’s overly broad interpretation of a part of the federal law against obstruction, saying it was meant to be limited to very specific acts such as destruction of documents.

“It is inconceivable to me that the department could accept Mueller’s interpretation,” Barr wrote. “It is untenable as a matter of law and cannot provide a legitimate basis for interrogating the president.”

At the time, Mueller’s team was pressing for an interview with the president, and Barr’s memo argued forcefully that no interview was justified because of what he viewed as Mueller’s erroneous, overly broad view of the obstruction law.

In what is arguably the most technical and dense section of the report, Mueller’s team pushes back hard against such arguments, saying the law in question is broad and “captures corrupt conduct, other than document destruction, that has the natural tendency to obstruct contemplated as well as pending proceedings.”

In the same section describing the Mueller team’s view of obstruction law, they again suggested that Congress could make such a determination.

“Congress can validly regulate the President’s exercise of official duties to prohibit actions motivated by a corrupt intent to obstruct justice,” the report said.

Barr plans to testify to Congress in two weeks, setting the stage for more questions about his disagreements with Mueller.