The exchange started when Mr. Trump called a judge who had ruled against his administration’s asylum policy “an Obama judge.” In response, the chief justice said the president had misunderstood the role of the federal courts in the constitutional system.

“We do not have Obama judges or Trump judges, Bush judges or Clinton judges,” Chief Justice Roberts said in a statement. “What we have is an extraordinary group of dedicated judges doing their level best to do equal right to those appearing before them. That independent judiciary is something we should all be thankful for.”

Mr. Trump took issue with the chief justice’s statement on Twitter. “Sorry Chief Justice John Roberts, but you do indeed have ‘Obama judges,’” Mr. Trump wrote, “and they have a much different point of view than the people who are charged with the safety of our country.”

On Tuesday, the chief justice returned to his theme. “We should celebrate our strong and independent judiciary, a key source of national unity and stability,” he wrote. “But we should also remember that justice is not inevitable.”

The friction with the president has only added to the delicate spot the chief justice will find himself in when he takes on his constitutionally assigned duty to preside over Mr. Trump’s Senate trial. Mr. Trump has repeatedly pinned the future of his presidency on the trial, the details and timing of which have not been set.

Chief Justice Roberts’s report concentrated on the central role the judiciary has played in educating the public, notably by issuing accessible decisions, in both senses of the word.

“When judges render their judgments through written opinions that explain their reasoning, they advance public understanding of the law,” he wrote. “Chief Justice Earl Warren illustrated the power of a judicial decision as a teaching tool in Brown v. Board of Education, the great school desegregation case. His unanimous opinion on the most pressing issue of the era was a mere 11 pages — short enough that newspapers could publish all or almost all of it and every citizen could understand the court’s rationale. Today, federal courts post their opinions online, giving the public instant access to the reasoning behind the judgments that affect their lives.”