President Trump and presumptive Democratic presidential nominee Joe Biden have both made shaping the Supreme Court’s agenda central to their campaign pitches, with Biden promising to appoint the first black woman and someone who embraces abortion rights to the bench, while Trump has warned of an end to conservative governance if Biden has his way.

But a series of liberal decisions by the conservative-led Supreme Court this week is showcasing the shakiness of such promises, in an era when candidates of both parties are making increasingly explicit pledges to name justices who will faithfully carry out their agenda.

Two Republican-appointed members of the court, including Trump’s first pick, Neil M. Gorsuch, and Chief Justice John G. Roberts Jr., have made clear that their opinions will not always be predictable when it comes to issues important to Republicans. They each joined with liberal justices to defeat Trump administration priorities this week.

"Dreamers" across the country celebrated the Supreme Court ruling on June 18 that blocked the Trump administration’s attempt to end the DACA program. (Alonso Parra/The Washington Post)

The court has also refused to take up cases for the next term that had been championed by conservatives, including cases on gun rights and California’s sanctuary cities law.

These twists have deeply frustrated conservatives. “The left and the right are playing to a different set of rules,” said Ralph Reed, chairman of the Faith & Freedom Coalition, a conservative religious group, after the Gorsuch ruling on Monday. “They seem to be able to appoint people who largely if not universally hew to the party line. On the right it feels sometimes that at best you are batting .500 sometimes.”

The surprises have prompted both Trump and his Democratic opponents to redouble their arguments, as they head toward Election Day, on the need to build as big a court majority as possible. At the same time, they are injecting more anxiety and uncertainty into the process.

The stakes are high, with conservatives holding a narrow 5-4 majority on the court and Justice Ruth Bader Ginsburg, 87, widely expected to retire in the next few years, possibly along with other colleagues. That could give the next president the opportunity to influence the court for a generation.

The moves by Roberts and Gorsuch have also served to bolster the case, long made in public by Roberts, that the courts are not simple extensions of the political branches of government. “We do not have Obama judges or Trump judges, Bush judges or Clinton judges,” Roberts said in 2018, after Trump verbally criticized a federal judge.

Democratic court-watchers caution that this week’s rulings may not define the court term. The court is expected to issue opinions as soon as next week that could favor Trump and the Republican Party on questions regarding the release of Trump’s tax returns, abortion restrictions in Louisiana, religious exemptions to contraception mandates and the structure of the Consumer Financial Protection Bureau.

“I don’t think that people should form judgments yet about the trajectory of this conservative majority yet until these rulings are out,” said Brian Fallon, executive director of Demand Justice, a progressive group that has supported restructuring the court to weaken the conservative influence.

For advocates on the right, however, the shocks of this week revive previous traumas that dates back to the presidencies of Dwight D. Eisenhower and Ronald Reagan, who appointed justices who repeatedly ruled against the conservative movement’s priorities, especially later in their careers.

The decision by Gorsuch to chart his own course is particularly painful for some conservatives, given that he was vetted for Trump by a small network of conservative legal scholars, including leaders of the Federalist Society, who offered public assurances of their credentials.

After this week’s ruling on gay rights, conservative writer Varad Mehta despaired of the years-long push to elevate conservative justices.

“The whole point of the Federalist Society Judicial project, the whole point of electing Trump to implement it, was to deliver Supreme Court victories to social conservatives,” he tweeted. “If they can’t deliver anything that basic, there’s no point to either.”

But other conservatives cautioned against overinterpreting the recent opinions, which amounted to a small slice of the decisions issued by the court this term. “Justices Gorsuch and Kavanaugh were the most-vetted justices in history by a Republican president. Their records were robust and the process was thorough,” said Carrie Severino, president of the Judicial Crisis Network, a conservative group. “That said, I’m sure the process can be improved even further — as it has in the last several decades — for the sake of advancing the rule of law even more so.”

Trump, during the 2016 campaign, announced a list of potential appointees to assure conservatives that he would pick someone to their liking, an apparently successful effort to persuade some on the right who were otherwise uncomfortable with Trump to support him.

In response to the rulings this week, Trump promised to double down on the strategy, though he has not yet publicly acknowledged that it was Gorsuch’s vote the undermined his administration’s fight to prevent workplace protections for gay, lesbian and transgender employees.

“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,” Trump wrote on Twitter. “Do you get the impression that the Supreme Court doesn’t like me?”

The Trump campaign has argued the court debate will once again work to its benefit this year.

“The President’s record appeals to conservatives who supported him in 2016,” Trump campaign spokesman Tim Murtaugh said. “Contrast that with the vision of Joe Biden, who has proven he will bend to the will of the extreme left, and has even been endorsed by Planned Parenthood, which supports abortion-on-demand.”

But Democratic voters, long thought to care less about the court than their GOP counterparts, may have begun to close the gap in their interest in judicial selection.

“Progressives are galvanized on this issue of the courts like never before,” said Nan Aron, president of the Alliance for Justice, a liberal group focused on judicial selection.

One galvanizing episode was Senate Majority Leader Mitch McConnell’s refusal to allow a hearing for former president Barack Obama’s final Supreme Court pick, Merrick Garland. That kept the spot open until Trump won, allowing him to appoint Gorsuch instead and seal the court’s conservative majority.

Democrats were upset enough by the conservative strength on the court that several candidates in the recently concluded presidential primaries embraced plans to remake the structure of the court, by expanding its membership or rotating justices off the bench.

Biden did not embrace those plans, though he did back down from his past opposition to “litmus tests” around court picks. As a senator, he voted against the confirmations of Roberts and Justice Clarence Thomas and in favor of the more liberal justices on the court.

Biden praised Thursday’s decision, on procedural grounds, to allow the continuation of the Deferred Action for Childhood Arrivals program, which allows undocumented immigrants brought to the United States as children to stay in the country.

“The Supreme Court’s ruling today is a victory made possible by the courage and resilience of hundreds of thousands of DACA recipients who bravely stood up and refused to be ignored,” Biden said. “As Justice Roberts said, the Trump administration’s action was capricious and arbitrary.”

During his 2016 campaign, Trump was explicit in promising policy outcomes from his Supreme Court picks. During a presidential debate, he predicted that Roe v. Wade would be overturned “automatically” if he was able to appoint two or three justices to the court. Since he took office, he has been able to appoint two justices to fill seats that had previously been filled by Republican nominees.

Another court pick is likely during the president’s next term. Ginsburg has suffered four bouts with cancer and was hospitalized earlier this year for the nonsurgical treatment of a gallbladder condition. Many court-watchers expect her to step down during the next presidential term.

Republican strategists, who credit the 2018 confirmation of Justice Brett M. Kavanaugh for increasing GOP turnout in the midterm elections, say a vacancy on the court this year would be a political boon.

“A court pick or two would change everything,” said Scott Reed, a Republican strategist who works for the U.S. Chamber of Commerce. “There is nothing that energizes the conservative electorate like the Supreme Court.”

Public perceptions of the court have shifted amid increased partisanship in recent years, with disapproval of the way the court is handling its job peaking at 52 percent in 2016 before falling to 42 percent last year, according to Gallup. A poll last year by Marquette University Law School found that 36 percent of the country said politics mainly motivated the court’s decisions, compared to 64 percent who said it was mainly the law.

Roberts, as the leader of the court, has made maintaining the public perception of the court a top priority.

In addition to responding to Trump’s comments on occasion, after Senate Minority Leader Charles E. Schumer (D-N.Y.) warned last March that Gorsuch and Kavanaugh would “pay a price” for voting against abortion rights, Roberts said “threatening statements of this sort . . . are dangerous.” He also promised that the justices “will continue to do their job, without fear or favor, from whatever quarter.”

An appointee of George W. Bush, Roberts has periodically sided with liberals on the court in key moments, including a case that preserved key parts of the Affordable Care Act and a case that rejected the Trump administration’s desire for a citizenship question in the 2020 U.S. Census.

That has not earned him the trust of liberals.

“Roberts is playing a little bit more of a long game and trying to bend the arc of the universe just a bit more slowly,” Fallon said. “He is trying to achieve those same gains that his colleagues on the conservative majority have in mind, but to do it off the front pages.”

Whatever the end goal, the Roberts approach is likely to decrease public pressure on more radical changes that would remake the structure or balance of the court.

“Roberts strikes me as someone who is cognizant about how the court is being perceived,” said Daniel Epps, an associate professor of law at Washington University in St. Louis. “The more the court continues to hand out victories to both sides in the culture wars, both sides in our political community, the harder it is for those kinds of proposals to get traction.”