But Ms. Klobuchar’s votes shifted in 2019, the year she announced her presidential campaign. Last year, Ms. Klobuchar voted for far fewer of Mr. Trump’s judges over all and none of his appeals court nominees, according to Demand Justice — a shift her campaign attributes to a protest by Democratic senators to rule changes forced through by Republicans in early 2019.

For Ms. Klobuchar, that record puts her at odds with a party base that sees any compromise with the president as a capitulation to an administration many view as corrupt and immoral. Her decision to back many of Mr. Trump’s judicial nominees in the first two years of his administration threatens to undermine a central theme of her candidacy: that Ms. Klobuchar is a battle-tested legislator who has been “in the arena” fighting for progressive values in the Senate.

“Amy Klobuchar was an accomplice in the conservative capture of the courts,” said Meagan Hatcher-Mays, the director of democracy policy for Indivisible, a liberal grass-roots group that sprang up after Mr. Trump’s election and has not made an endorsement in the primary race. “What a lot of people don’t understand is that Trump is temporary but these judges are there for life.”

More than three years into his presidency, Mr. Trump has installed judges at the fastest pace of any president in decades. If current trends hold, a quarter of federal judges will be Trump appointees by the end of this year, according to an analysis by The Economist. Even if Mr. Trump loses in November, those justices will remain on the bench, leaving them in position to impede or block the liberal proposals that Democratic presidential candidates like Ms. Klobuchar promise to deliver.

Their impact is already apparent.

Less than a year after Judge Kurt D. Engelhardt was nominated by Mr. Trump and confirmed by the Senate to the U.S. Court of Appeals for the Fifth Circuit, he voted to strike down part of the Affordable Care Act in December, putting the health care law in legal limbo.