WASHINGTON — William P. Barr, President Trump’s nominee for attorney general, assured senators at his confirmation hearing on Tuesday that he would permit the special counsel, Robert S. Mueller III, to complete the Russia investigation and said he was determined to resist any pressure from Mr. Trump to use law enforcement for political purposes.

Mr. Barr, whose confirmation seems virtually assured, pointed to his age and background — he served as attorney general from 1991 to 1993 — as buffers to potential intrusions on the Justice Department’s traditional independence. He suggested he had no further political aspirations that might cloud his judgment, the way that future ambitions might give pause to a younger nominee, as well as the experience to fight political interference.

“I am in a position in life where I can provide the leadership necessary to protect the independence and reputation of the department,” Mr. Barr, 68, told the Senate Judiciary Committee, adding that he would not hesitate to resign if Mr. Trump pushed him to act improperly.

“I will not be bullied into doing anything I think is wrong — by anybody, whether it be editorial boards or Congress or the president,” Mr. Barr said. “I’m going to do what I think is right.”