Matthew G. Whitaker, in his first and likely last appearance before Congress as acting attorney general, sparred for hours Friday with Democrats who sternly warned him not to impede special counsel Robert S. Mueller III’s investigation of Russian interference in the 2016 presidential campaign.

Whitaker, who took command of the Justice Department in November and is likely to leave the job next week with the expected confirmation of William P. Barr to serve as attorney general, told members of the House Judiciary Committee that he had not influenced Mueller’s probe in any way and had not spoken to President Trump about the investigation since his appointment.

In a series of chippy exchanges with Democrats who questioned his credentials, judgment and integrity, Whitaker adopted a confrontational tone that often left lawmakers exasperated.

Over and over, he refused to detail his conversations with the president — prompting the committee’s chairman to end the hearing by threatening a subpoena if follow-up questions weren’t answered. Whitaker carefully watched the clock, at one point noting the chairman’s five-minute window to ask questions had expired.

More substantively, Whitaker refused to disagree with the president’s characterization of Mueller’s probe as a “witch hunt” — something other top law enforcement officials and Trump nominees have not hesitated to do.

“It would be inappropriate for me to talk about an ongoing investigation,” Whitaker said several times when asked if he thought Mueller’s work matched that description.

From the hearing’s opening minutes, Whitaker was pressed by Democrats to explain his role in overseeing Mueller’s investigation, while Republicans focused their questions mostly on the administration’s policies.

The acting attorney general sought to impress upon them that, under his stewardship, it was business as usual for the special counsel.

“There has been no change in the overall management of the special counsel investigation,” Whitaker said. “I have and will continue to manage this investigation in a manner that is consistent with the governing regulations.”

Democrats seemed unconvinced.

In one notable moment, Rep. Hakeem Jeffries (D-N.Y.) hailed the special counsel’s work as an important national security investigation and asserted that “the fact that people suggest otherwise comes dangerously close to providing aid and comfort to the enemy.”

Then he offered Whitaker a stern warning for what are expected to be his final days in office. “Keep your hands off the Mueller investigation,” Jeffries said.

At times, Whitaker seemed to avoid answering lawmakers’ question directly — although he offered some unequivocal pronouncements.

He said, for example, “I have not talked to the president of the United States about the special counsel’s investigation,” and added that he hadn’t discussed the matter with White House officials.

But on a separate Trump-related investigation, Whitaker hedged. He disputed a news report that the president had lashed out at him after Michael Cohen, Trump’s former lawyer, pleaded guilty to various crimes in federal court in New York.

“No, he did not,” Whitaker answered after several attempts to evade the question of whether Trump had berated him.

Later, under aggressive questioning from Rep. Val Demings (D-Fla.), Whitaker declined to say whether he had ever talked with Trump about the Cohen case or the federal prosecutors in Manhattan who handled it.

“I am not going to discuss my private conversations with the president of the United States. No matter what the question is,” ­Whitaker said.

He similarly tried at first to evade questions about whether he had approved investigative steps in the Mueller probe, and he would never say when or how often he has been briefed on that investigation. At the end of a particularly contentious exchange with the committee’s chairman, Rep. Jerrold Nadler (D-N.Y.), Whitaker tried to point to the clock as a reason for him to not have to answer.

“Mr. Chairman, I see that your five minutes is up,” Whitaker said, prompting laughter in the hearing room. In congressional hearings, committee chairman control the time for questions, not other lawmakers or the witnesses.

Eventually, Whitaker relented and answered Nadler’s question.

“We have followed the special counsel’s regulations to a ‘T,’ ” Whitaker said. “There has been no event, no decision, that has required me to take any action, and I have not interfered in any way with the special counsel’s investigation.”

The committee’s top Republican, Rep. Douglas A. Collins (Ga.) periodically interrupted Democrats to note that the hearing was supposed to be about Justice Department oversight, but few questions seemed to be focused on broad Justice Department issues.

“This hearing is pointless!” Collins erupted at one point, accusing Democrats of “political grandstanding” and “character assassination.”

Democrats did press Whitaker on non-Mueller topics, chief among them the department’s zero-tolerance policy that led to children being separated from their families when trying to enter the U.S. illegally at the southern border. But the hearing was also not short on theatrics.

When Whitaker made another comment about speaking time, Rep. Sheila Jackson Lee (D-Tex.) admonished the country’s top law enforcement official: “Mr. Attorney General, we’re not joking here, and your humor is not acceptable.”

Whitaker sought to clarify that when he said at a recent news conference that Mueller’s probe was “close to being completed,” he was not necessarily speaking for Mueller, who was “going to finish his investigation when he wants to finish his investigation.” But Whitaker did seem to suggest that the comment came from his knowledge as the official overseeing the special counsel investigation.

“That position that I mentioned last week in a press conference was my position as acting attorney general,” Whitaker said.

He defended his decision not to recuse himself from the Mueller probe — despite his past public comments that were critical of it — and identified for the first time the official who said he should probably step aside: Brad Weinsheimer, the Justice Department’s senior career official.

“It was my decision to make,” Whitaker said.

Some of the Democrats’ questioning focused on Whitaker’s time as a pundit for CNN and as leader of a conservative nonprofit, before coming back into the Justice Department.

Whitaker revealed new details about his discussions during that period about serving as a White House attorney, potentially putting him opposite the Justice Department, handling the response to the Russia probe. He said he talked about the position with then-White House Counsel Donald McGahn’s chief of staff, but they mainly discussed Whitaker’s experience and steered clear of topics specific to Mueller’s inquiry.

“They did not want to talk about the investigation because the folks were dealing with that investigation, and that’s why they wanted someone who had been unrelated to the investigation and the campaign,” Whitaker said.

Whitaker also addressed a question that has long been drawn the curiosity of Democrats: Who funded the nonprofit that paid him more than $1.2 million before he came to work for the Justice Department?

Rep. Eric Swalwell (D-Calif.) asked if the Foundation for Accountability and Civic Trust, which described itself as a watchdog dedicated to exposing unethical conduct by public officials, had a foreign donor supporting it.

“I don’t actually know the answer to that,” Whitaker said. He added that he did not believe so and said, “Our main donor was a group that was a U.S. entity.” That entity, he said later, was a group called Donors Trust.

That Whitaker appeared at all is notable. On Thursday, the acting attorney general had said he would not testify before the committee as scheduled unless committee Democrats gave him assurances he wouldn’t be subpoenaed, as they had threatened to do. But after negotiations that lasted into the night, Nadler agreed no subpoena would be issued Thursday or Friday, and Whitaker agreed to appear.

Nadler said at the conclusion of the hearing that a subpoena was still possible if Whitaker did not adequately respond to follow-up questions. It is unclear, though, what the committee’s appetite would be for issuing a subpoena after Whitaker leaves government.

Karoun Demirjian contributed to this report.