Just months before President Donald Trump stands for reelection, his central pitch to conservatives -- that he has remade the US justice system in their image -- is unravelling.
Twice this week the Supreme Court dealt defeats on issues dear to Trump's supporters: it expanded equal protection rights to gay and transgender people, and sustained protections for certain undocumented immigrants that Trump had sought to end.
It was not supposed to be this way. In his three and a half years in office Trump has replaced two of the nine justices, seemingly tilting the high court to the right for years to come.
But the two rulings this week favored the left -- angering conservatives and threatening Trump's reelection.
"I think that what has happened could be critical to the campaign," said Carl Tobias, a law professor at the University of Richmond.
"Many Trump supporters hold their noses and vote for him because of the judges whom he appoints. But this week seems to show that he cannot deliver on that promise," he told AFP.
Keeping a promise
In 2016 the New York billionaire captured the support of the powerful religious right by promising to fill federal courts with judges who are against gun regulation, abortion, gay marriage, and other flashpoint issues.
Trump has kept his pledge, naming 195 conservative judges, significantly shifting the pool of 860 federal judges to the right.
The centerpiece was naming Neil Gorsuch and Brett Kavanaugh to the Supreme Court, cementing an apparent 5-4 tilt to the right.
On Thursday the Senate confirmed another Trump pick, Justin Walker, to the Washington, DC Court of Appeals.
Critics say the 37-year-old is much too inexperienced to sit on one of the country's most powerful courts. But he is closely tied to Republicans.
As the White House points out, the average age of Trump's judges is under 50, ensuring they "will make a lasting impact on the courts for decades to come."
A week of setbacks
But on Monday, Gorsuch and Chief Justice John Roberts stunned observers in siding with the four Democratic-appointed justices to extend equal rights protections to gay and transgender people.
The same day the court refused to take up two administration-backed cases: one to rule on its powers to round up illegal immigrants, the second to rule on gun restrictions dislike by conservatives.
Then on Thursday Roberts joined the four liberals to overrule a hallmark of Trump's anti-immigration policies, his cancellation of the Deferred Action for Childhood Arrivals (DACA) program that gives legal protections to some 700,000 undocumented immigrants brought to the United States as children.
That added to concerns on the right that Roberts is not the conservative people expected when appointed by Republican president George W. Bush in 2005.
Trump 'really bad' at law
Trump lashed out, calling the DACA decision "highly political" and "seemingly not based on the law."
"Do you get the impression that the Supreme Court doesn't like me?" he tweeted.
"These horrible & politically charged decisions coming out of the Supreme Court are shotgun blasts into the face of people that are proud to call themselves Republicans or Conservatives."
Analysts faulted Trump for making it personal.
"It shows how ignorant is Trump's belief that he can manipulate the Supreme Court by appointing justices who will rubberstamp his illegal behavior," said Tobias.
Texas law professor Steve Vladeck said Trump's policies and orders are often legally unsound to begin with.
"It's not that Chief Justice Roberts is a closet progressive. He's not. It's that the Trump administration is *really bad* at administrative law," Vladeck wrote on Twitter.
Trump sought to turn the setbacks to his advantage, promising more conservative judges if he is reelected.
"I will be releasing a new list of Conservative Supreme Court Justice nominees ... by September 1, 2020," or two months before the election, he said.
"Based on decisions being rendered now, this list is more important than ever before."