(CNN) President Donald Trump will exit the White House on Wednesday but leave behind three of the nine Supreme Court justices and a majority that was willing to partner with him for much of his agenda.
Trump's imprint on the Supreme Court and overall three-tier federal judiciary represents one of the most significant right-wing successes of his tenure, even as his instigation of the US Capitol assault and final destructive days appear to be leaving the most indelible mark of his legacy.
With forceful leadership from Senate Majority Leader Mitch McConnell, Senate Republicans enabled Trump to make lifetime appointments to nearly 30% of the 870-seat federal bench. A majority of the powerful US appellate courts are now dominated by Republican appointees.
RELATED: A four-year timeline of Donald Trump and the Supreme Court
At the Supreme Court, the Trump administration won more than it lost during the past four years, largely prevailing as it argued against immigrants' rights and for corporate interests. The conservative majority endorsed Trump's rush to execute 13 federal defendants in recent months and last week reinstated restrictions on women trying to obtain a prescribed abortion drug.
The justices also have delayed for months action on the latest chapter of a Manhattan district attorney's long-pending subpoena for Trump tax returns.
The Supreme Court and lower US court judges, however, failed to give Trump what he desired most at the end. They swatted away his attempts to discard valid 2020 presidential election results. For that, Trump called the Supreme Court "totally incompetent and weak."
One person who stood between Trump and more sweeping success was Chief Justice John Roberts. The administration lost major cases at the Supreme Court when Roberts gave his decisive vote to the liberal side of the bench.
Still, Roberts often afforded the administration some measure of victory even in its losing cases, such as a broader reading of executive discretion under the Administrative Procedure Act, or a chance to return with stronger arguments.
When the administration tried to add a citizenship question to the 2020 census and wanted to end the Obama-era "Dreamers" program for undocumented immigrants who came to the US as minors, the Trump arguments were hurt by contrived and flawed justifications as much as anything.
Trump responded to the Roberts' opinion in the dispute over the program known as Deferred Action for Childhood Arrivals by saying, "Do you get the impression that the Supreme Court doesn't like me."
Trump and conservative advocates effectively triumphed on a goal dating to the 2016 election campaign when Trump took the unorthodox step of issuing a list of possible candidates for the high court, and McConnell ensured that the vacancy caused by that February's death of Justice Antonin Scalia was waiting for the new president.
Just days after taking office in January 2017, Trump nominated US appeals court Judge Neil Gorsuch to fill the Scalia vacancy.
The next year, Trump appointed Brett Kavanaugh to succeed Justice Anthony Kennedy, who retired after 30 years on the bench. Four months ago, a new vacancy suddenly appeared with the September 18 death of prominent liberal Ruth Bader Ginsburg, for whom Trump chose Amy Coney Barrett.
McConnell had also stalled on Obama lower court nominations in 2016, ensuring that about 100 lower court vacancies also awaited Trump in 2017. After four years, the President has filled 177 of the 682 district court judgeships (26%) and 54 of the 179 appeals court judgeships (30%), according data compiled by the Brookings Institution's Russell Wheeler.
When Trump first came to office, four of the 13 US appeals courts had Republican majorities, Wheeler said, and today, seven of the 13 are now dominated by GOP appointees. These regional appeals courts usually have the last word on legal disputes because the Supreme Court accepts fewer than 1% of the petitions that arrive at its door.
Of cases that were heard by the justices, Trump generally saw bigger victories at the start of its tenure than the finish, beginning with the June 2018 decision that upheld Trump's travel ban. In a 5-4 opinion written by Roberts, the majority called Trump's order "an act that is well within executive authority and could have been taken by any other President."
Over protests from dissenting liberals to consider Trump's anti-Muslim rhetoric, Roberts wrote in Trump v. Hawaii that the court must consider "the authority of the Presidency itself."
In a case that drew far less attention but reinforced the Trump agenda limiting eligibility for asylum in the US, the justices in June curtailed court review for asylum seekers in an expedited removal process who claim they cannot return home because they have a credible fear of torture or death.
The administration won several major cases favoring employers over labor. In one of the most contentious, the five-justice bloc on the right in 2018 reversed a 1977 ruling that had allowed states to require employees who declined to join a union to pay "fair share" fees to finance bargaining for pay and benefits but not political activities.
"Big loss for the coffers of the Democrats!" Trump wrote on Twitter after the ruling.
Equally consequential were some decisions that arose through Trump requests on the so-called "shadow docket," which were never fully briefed and heard in oral arguments.
Department of Justice lawyers repeatedly persuaded the conservative majority to block adverse lower court orders that would have prevented the administration from enforcing its initiatives while legal challenges were pending.
The justices by 5-to-4 votes, conservatives over liberals, let Trump divert funds to build the wall at the US southern border; to institute a new rule disadvantaging green-card applicants who seek food stamps and other public assistance; and, most recently, to reinstate a Food and Drug Administration requirement that women prescribed mifepristone, to end a pregnancy in its early weeks, pick up the pill in person at a hospital or clinic despite the Covid-19 pandemic.
One of Trump's most conspicuous losses appeared, at the time, to be July 2020 rulings rejecting his attempt to block subpoenas from US House committees and the Manhattan district attorney for his personal business records.
But the compromise 7-2 court decisions offered Trump additional ways to fight the subpoenas, and by the end of 2020 Trump had relinquished none of the disputed financial documents.
The decision in Trump v. Vance regarding a Manhattan grand jury's subpoena had appeared most lethal to Trump's desire to keep records secret. Reaching back 200 years in court history, Roberts wrote, "No citizen, not even the president, is categorically above the common duty to produce evidence when called upon in a criminal proceeding."
After that July 9 decision on the subpoena directed to Trump's accounting firm, Mazars USA, lower court judges reviewed new Trump defenses that the subpoena was overly broad and issued in bad faith.
The Trump claims were again spurned, and in October the 2nd US Circuit Court of Appeals wrote that "there is nothing to suggest that these are anything but run-of-the-mill documents typically relevant to a grand jury investigation into possible financial or corporate misconduct."
Manhattan District Attorney Cyrus Vance has been seeking the financial records as he investigates any Trump or Trump Organization involvement in "hush money" payments to women who alleged sexual affairs with him during the 2016 presidential campaign. Trump has denied the affairs.
Trump's lawyers in October asked the Supreme Court to postpone the effect of the Second Circuit decision and hear the merits of their defense. Vance's lawyers countered, "This litigation has already substantially hampered the grand jury's investigation."
For the past three months, the justices have not acted -- with no public explanation.
Despite his many victories and what will be a transformative legacy, Trump, of course, always wanted more and suggested he was being denied the respect he deserved.
Last July, when the Supreme Court spurned Trump's immunity claim and sent the Vance case back to lower courts, Trump wrote on Twitter, "I have to keep fighting in a politically corrupt New York. Not fair to this Presidency or Administration! .... Courts in the past have given 'broad deference.' BUT NOT ME!"