WASHINGTON — Soon after he undercut President Trump’s baseless claims of widespread voter fraud in early December, Attorney General William P. Barr’s time atop the Justice Department hurtled to its end. The president and his allies attacked Mr. Barr in public and private, making clear that he should retract his assessment or spend the last weeks of the administration belittled and possibly fired in humiliating fashion.
Mr. Barr got to work on a face-saving exit plan, according to people familiar with his efforts. He and allies began back-channel communications with the White House to gauge his chances at an amicable parting, and he spent a weekend writing a letter that would announce his departure while preserving his relationship with the president.
The effort succeeded in allowing Mr. Barr to leave largely on his terms. Mr. Trump heaped praise on Mr. Barr in announcing his exit, and the attorney general returned the favor, blurring the fact that he had been all but pushed out.
The orchestrated farewell was a reflection of how Mr. Barr navigated his tenure running a Justice Department for a president who viewed it as hostile toward him. Mr. Barr’s time was largely defined by the perception that he set aside the department’s independence to advance the president’s political and personal interests, chiefly by undermining its own investigation into Russia and the Trump campaign and by wading into campaign issues, including playing up fears of voter fraud.
But Mr. Barr also showed flashes of autonomy at the end of his tenure. His reversal on voter fraud broke from the president. He said he saw no need for a special counsel to investigate President-elect Joseph R. Biden Jr.’s son Hunter as Mr. Trump clamored for one. And Mr. Barr even acknowledged that some of his suspicions about the Obama administration’s examination of Russian election interference were misguided.
Historians will debate whether Mr. Barr, 70, was trying to preserve his reputation. Already a polarizing figure, he had faced a new groundswell of criticism in recent weeks for easing restrictions on election-related investigations as Mr. Trump ramped up his complaints about voting irregularities and for ensuring that the department’s examination of the Russia investigation continues into the Biden administration.
Mr. Barr’s allies say he simply followed his instincts, honed by his maximalist view of executive power, and was untroubled by perceptions that he was serving Mr. Trump’s personal agenda.
Either way, an examination of Mr. Barr’s tenure, based on interviews with allies, critics, current and former law enforcement officials and academics, shows that no matter what Mr. Barr says or does, Mr. Trump will ultimately define his legacy as attorney general.
“Bill Barr will be inexorably tied to Donald Trump,” said Nancy Baker, a political scientist who studies attorneys general and interviewed Mr. Barr for an oral history project by the Miller Center at the University of Virginia. While administration critics credited Mr. Barr for refuting Mr. Trump’s false election assertions, ultimately, she said, “he will always be Trump’s guy.”
Mr. Barr, who left the job last week, said at his final news conference that he accepted the post because he felt he could help the department during a fraught period.
“I knew I was signing up for a difficult assignment in this department. As I’ve said, there were rough times,” said Mr. Barr, who declined to answer questions for this article. “I don’t regret coming in because I think it’s always an honor to serve the nation.”
When Mr. Barr, who had been attorney general during the first Bush administration, returned to the office early last year, some Trump critics viewed his experience as a potential check on the president. But his own record showed that Mr. Barr regarded presidential power as broad, and Mr. Trump offered a chance to restore what Mr. Barr saw as executive authority lost in the post-Watergate era.
“As a cabinet member, the attorney general was supportive of the administration and many of its priorities. He was unfairly criticized for that,” said Brian Rabbitt, his former chief of staff and the outgoing head of the Justice Department’s criminal division. “But you don’t take a job like his to resist. You take the job to help the administration do its best for the country.”
Mr. Barr was passionate about issues including expanding religious freedoms and supporting Native American reservations and tribal law enforcement offices, former colleagues said, and he largely continued his Bush-era fight against drugs, violent crime and what he deemed to be politically motivated prosecutions.
That work was eclipsed by the Russia investigation, which both he and Mr. Trump believed represented an abuse of power by the F.B.I.
“He had a vigilante attitude toward the Russia investigation — ‘I alone will fix this,’” said Rebecca Roiphe, a professor at New York Law School who studies the history and ethics of the legal profession.
After his February 2019 confirmation, Mr. Barr embarked on what department officials said was a single-minded mission to expose any wrongdoing by investigators.
Mr. Barr began by reshaping the public’s perception of the most politically charged investigation in a generation in the best possible light for Mr. Trump. He went on to frame it as a political cudgel used to “sabotage” Mr. Trump’s presidency, even after the Justice Department’s inspector general concluded otherwise. “Prosecutors can sometimes become headhunters, consumed with taking down their target,” Mr. Barr said this fall. He said in his final days in office that the investigators for the special counsel, Robert S. Mueller III, were too biased to expose F.B.I. wrongdoing.
Mr. Barr went beyond talk, tapping John H. Durham, the U.S. attorney in Connecticut, to open a criminal investigation into the origins of the Russia inquiry. Mr. Barr talked up Mr. Durham’s work in the months before the election, flouting Justice Department norms to avoid publicly discussing ongoing criminal investigations as Mr. Trump promoted the inquiry as certain to prove a “deep state” plot against him.
“He had a blind spot on Russia,” Ms. Baker said of Mr. Barr. “Blind to the fact that he acted politically in his treatment of the Russia investigation, even if in his mind he acted out of his belief that his actions were consistent with the rule of law.”
After the election, amid a storm of complaints from Mr. Trump’s allies that Mr. Durham had not revealed information that could have helped the president, Mr. Barr downplayed expectations that he would expose criminal acts. He told a Wall Street Journal opinion columnist that by focusing solely on indictments, the political class excuses other contemptible behavior.
And though in the same interview he backed off his suspicions of the C.I.A.’s examination of Russian election interference in 2016, he also confirmed Mr. Durham was still reviewing the 2017 intelligence community assessment about Russian election interference.
Inside the Justice Department, the turning point came with Mr. Barr’s interventions in two high-profile cases stemming from the Russia inquiry, those of Mr. Trump’s longtime friend Roger J. Stone Jr. and his former national security adviser Michael T. Flynn. Some prosecutors withdrew from the cases. A few left the department entirely. A typically discreet work force began to call for Mr. Barr’s resignation and accuse him of turning the department “into a shield to protect the president” and a tool for Mr. Trump to settle political scores.
Mr. Barr rebuffed those allegations, publicly rebuking Mr. Trump for opining on the Stone case. Former aides said Mr. Barr was conveying the message to both Mr. Trump and federal prosecutors that he acts based on his convictions, not politics.
But Mr. Barr’s interventions in ways that benefited Mr. Trump extended beyond the special counsel investigation. Examining Mr. Trump’s dealings with Ukraine that prompted impeachment, the Justice Department quickly determined he had not committed a campaign finance crime, well before the president’s broad efforts to pressure Kyiv came into focus.
The department also took on lawsuits over books written by Trump adversaries. In the case of the former national security adviser John R. Bolton, who had fallen out of Mr. Trump’s favor, it opened a criminal inquiry into whether he illegally disclosed classified information.
Being a successful attorney general “is not just about doing the right thing, it’s about preserving the legitimacy of the institution,” Ms. Roiphe said. “Even if he honestly held these beliefs, he addressed them in ways that were only respected by his own political followers.”
Some Justice Department officials believed that Mr. Barr privately honed the president’s belief that his attorney general was his political fixer and used that capital with Mr. Trump to protect the department, shielding it from blowback when it prosecuted cases that interfered in trade negotiations with China and to protect the F.B.I. director, Christopher A. Wray, from being fired over the president’s animosity toward the bureau.
Buffeted by attack, Mr. Barr kept an unusually small inner circle of aides and relied on them, rather than the heads of the department’s divisions, for advice, according to former officials.
Mr. Barr seemed to scorn input from elsewhere in the department, particularly from the career staff, as unnecessary noise that slowed down his fast deliberative process, former officials said.
Mr. Barr made his low opinion clear in a speech this year, saying that no successful organizations deemed decisions by low-level employees “sacrosanct” or deferred to “whatever those subordinates want to do.”
But he seemed blindsided by a string of miscues earlier this year, chiefly his leadership of the federal response to this year’s nationwide protests over racial injustice. Mr. Barr came under fire for ordering federal officers to clear a park near the White House in June just before Mr. Trump’s widely criticized photo op outside a church. Frustrating some in the White House, he also contradicted Mr. Trump’s explanation for sheltering in a bunker during protests.
And later that month, Mr. Trump distanced himself almost immediately from Mr. Barr’s dismissal of the top federal prosecutor in Manhattan.
In his final weeks, Mr. Barr began to see Mr. Trump’s agenda, which he supported, as separate from the president himself and his personal shortcomings, like his refusal to accept the results of the election, associates said.
Mr. Barr accepted Mr. Biden’s win and said no amount of fraud he had seen would overturn it. He had already resisted Mr. Trump’s pressure late in the campaign to prosecute Democrats.
He also kept quiet the potentially explosive news that Hunter Biden was under criminal investigation. Disclosing that, associates said, could have undermined a future Biden presidency, an act Mr. Barr saw as a potential echo of the investigation opened four years earlier into Mr. Trump.