U.S. President Donald Trump's nominee for attorney general, William Barr, told lawmakers on Tuesday he would protect a federal probe into Russian election meddling from political pressure, stressing he would bring independence to the job and not shy away from breaking ranks with the administration.

"I will not be bullied into doing anything that I think is wrong — by anybody, whether it be editorial boards or Congress or the president. I'm going to do what I think is right," Barr said at his confirmation hearing before the Senate judiciary committee.

Barr is expected to win confirmation in the Republican-controlled Senate to serve as the nation's top law enforcement officer, which would put him in charge of special counsel Robert Mueller's investigation into Russia's interference in the 2016 election and any possible collusion between Moscow and Trump's campaign.

"On my watch, Bob will be allowed to complete his work," Barr said in a prepared statement he released on Monday.

Democrats worry that Trump's administration may try to undercut the investigation, which has been a frequent target of the president and his allies.

Barr, who was attorney general under Republican President George H.W. Bush in the early 1990s, said his primary loyalty would be to the rule of law, not Trump. He said he did not seek out the job and was reluctant to accept when Trump offered it to him.

Committee chairman Lindsey Graham, centre, looks over at former chair Chuck Grassley as ranking member Sen. Dianne Feinstein looks on during Barr's confirmation hearing. (Jonathan Ernst/Reuters)

Trump frequently criticizes the Mueller probe as a "witch hunt" and has denied any collusion with Russia or obstruction of justice. Russia has denied U.S. intelligence agencies' findings that it interfered in the 2016 election.

Barr said Mueller should only be prevented from completing his work if there was cause, but said it was "unimaginable to me" that Mueller, given his record, would provide such a justification.

Won't commit to recusal

The special counsel is required to report his findings confidentially to the Justice Department. Barr stopped short of directly pledging to release Mueller's report, but he expressed general support for disclosing the findings, whatever they may be.

"For that reason, my goal will be to provide as much transparency as I can, consistent with the law," Barr said.

Some of Barr's comments on Tuesday raised questions as to how he could co-exist with a president who had not adhered to the type of arms-length relationship with the Justice Department his predecessors have.

If a president attempts to intervene in a matter that he has a personal stake in, that should be looked at as a breach of his constitutional duty. - William Barr, attorney general nominee

"If a president attempts to intervene in a matter that he has a personal stake in, that should be looked at as a breach of his constitutional duty," Barr said.

Trump has often assailed the department, the FBI, federal judges in cases the administration is pursuing, and the intelligence community with public criticism.

Barr said he agreed with Mueller's charge that Russian entities interfered in the election, or at least tried to do so.

When pressed by Vermont Democrat Pat Leahy whether he would recuse himself from decisions related to the special counsel probe should the department's ethics lawyers recommend that course, he gave a qualified answer.

"I will seek the advice, but under the regulations, I make the decision as head of the agency as to my own recusal," said Barr, adding he would make such a judgment "in good faith based on the laws and the facts that are evident at that time."

Barr says special counsel Robert Mueller should be allowed to complete his work. (Chip Somodevilla/Getty Images)

Barr faced tough questions from Democrats about an unsolicited, 19-page memo he wrote last year that called Mueller's probe "fatally misconceived" for examining whether Trump obstructed justice by firing FBI director James Comey in 2017.

"It does raise questions about your willingness to reach conclusions before knowing the facts, and whether you prejudge the Mueller investigation," said Sen. Dianne Feinstein, the Judiciary committee's top Democrat.

Pressed on unsolicited memo about Mueller

Barr said his memo did not question the legitimacy of the probe as a whole, but only expressed concerns that the special counsel might be improperly interpreting one aspect of the law.

"I think it was entirely proper," he said of the memo, saying it was not unusual for former Justice Department officials to share their views of legal matters. He said he had written a similar memo criticizing the department's corruption case against Sen. Bob Menendez, a Democrat, which ended in a mistrial in 2017.

Barr also sent the memo to White House lawyers and discussed it with Trump's personal attorneys and a lawyer who represents Trump's son-in-law, Jared Kushner, he said in a letter to new committee chairman Lindsey Graham.

Barr could benefit from the fact that some Democrats view him as a better option than the man who took over the job after Trump forced out Jeff Sessions last year, acting attorney general Matt Whitaker.

Barr said he believed Sessions was right to recuse himself from matters involving the special counsel probe — a decision Trump railed against during Sessions's time in the office.

Barr also previously said the president's firing of Comey was appropriate, and that the Mueller prosecution team, criticized by Trump for including prosecutors who have contributed to Democrats, should have had more "balance."

Barr said he has been communicating with deputy attorney general Rod Rosenstein in anticipation of the role and has "no concrete plans" to usher him out.

He also expressed his commitment to the federal law protecting whistleblowers despite historic comments in which he was critical of the act.

Says Roe v. Wade is 'established precedent'

The nominee said he would faithfully uphold the recently passed First Step Act aimed at criminal justice reform. During his first tenure, Barr was part of a push for the most severe punishments available as the country was grappling with near historic violent crime rates.

Barr stated his belief in the early 1990s that the landmark Roe v. Wade decision that helped establish a woman's right to privacy in choosing to undergo an abortion "does not have any constitutional underpinnings" and would eventually be overturned.

Barr said Tuesday he didn't foresee the administration asking for the decision to be overruled and that he would "absolutely" support existing laws that set out the limits of protest outside clinics.

"I think the justices, the recent ones, have made clear that they consider Roe v. Wade an established precedent. It's been on the books 46 years," Barr said.

Barr was unanimously put forth by a Senate judiciary committee led by Joe Biden in 1991, making him the 77th attorney general in the country's history at the time.

He admitted in his opening statement that he had to think about taking on the role again more than two decades later.

"When my name was first raised, I was reluctant to be considered," he said. "I am 68 years old, partially retired and nearing the end of a long legal career."