(CNN) -- Attorney General William Barr on Thursday rebuked President Donald Trump for publicly commenting on sensitive investigations but insisted the Justice Department had acted appropriately after an extraordinary falling out with career prosecutors who had handled the case of Roger Stone earlier this week.

In an interview with ABC News, Barr provided a robust defense of the department's rank-and-file and said Trump's online missives made it "impossible" to do his job.

"I cannot do my job here at the department with a constant background commentary that undercuts me," Barr said.

"To have public statements and tweets made about the department, about people in the department, our men and women here, about cases pending in the department and about judges before whom we have cases, make it impossible for me to do my job and to assure the courts and the prosecutors in the department that we're doing our work with integrity," he said.

The criticism was a notable zag for Barr after days of mounting scrutiny over his role in the fraught decision to publicly disavow prosecutors who had sought a stiff punishment for Stone, a longtime friend of Trump. The President had tweeted congratulations Barr for the move, provoking protest from Democrats who demanded an investigation.

The four career attorneys who had worked on the Stone case and signed off on the original sentencing memorandum each withdrew from the case on Tuesday in an apparent protest.

william-barr-1

Attorney General William Barr

On Thursday, Barr said he was "a little surprised" that the prosecutors had stepped down, and told ABC News that it was "preposterous" to characterize his role in the developments this week as an intervention. He argued he had merely acted to resolve an internal department dispute.

He has not spoken with the prosecutors, he added.

Barr told ABC that he hoped the President would react and respect the criticism of his tweets delivered in the interview.

"I hope he will react," Barr said.

A White House official said Trump is not upset with Barr after his comments to ABC.

Earlier this week, Trump insulted the career Justice Department attorneys who handled the Stone case, saying they had been "exposed for recommending a ridiculous 9 year prison sentence" and insinuating that they were "Mueller people."

Two of the attorneys had worked under former special counsel Robert Mueller, while the other two had picked up the case when it was transferred to the DC US attorney's office.