(Reuters) - A liberal-leaning California-based federal appeals court that has often ruled against President Donald Trump dealt him another setback this week in a major immigration case and soon could be asked to weigh in on a pipeline project he has championed.

FILE PHOTO: U.S. President Donald Trump talks to reporters prior to departing for Paris, France from the South Lawn of the White House for in Washington, U.S., November 9, 2018. REUTERS/Kevin Lamarque/File Photo

The 9th U.S. Circuit Court of Appeals, based in San Francisco, has been a thorn in Trump’s side since he took office last year and has drawn the Republican president’s ire for its decisions in high-profile cases.

His latest setback before the 9th Circuit came on Thursday when a three-judge panel rejected his bid to rescind a program launched by his Democratic predecessor, Barack Obama, that protects from deportation hundreds of thousands of illegal immigrants brought into the country as children.

The 9th Circuit has handed him defeats on his travel ban targeting people from several Muslim-majority countries and his bid to withhold federal funds from so-called sanctuary cities that limit cooperation on immigration enforcement. It also is set to rule on the administration’s appeal of a judge’s order blocking Trump’s move to put restrictions on transgender people serving in the U.S. military.

The 9th Circuit would hear any appeal by Trump’s administration of the ruling late on Thursday by a federal judge in Montana blocking construction for environmental reasons of the Keystone XL pipeline project that is designed to carry heavy crude oil from Canada to the United States.

The Justice Department said on Friday it is reviewing the Keystone XL ruling to decide its next step. TransCanada Corp said it remains committed to building the $8 billion, 1,180-mile (1,900-km) pipeline.

“The 9th Circuit is an easy punching bag for Trump because not only has it been traditionally liberal but California is its beating heart, and we all know how Trump fares in California,” said Barry McDonald, a law professor at Pepperdine University in Malibu. “He probably sees much of the West Coast as a nemesis for him.”

California, the most populous U.S. state, is a liberal bastion that is unfriendly political territory for Trump.

‘A FAIR DECISION’

Slideshow ( 2 images )

The president regularly belittles the 9th Circuit, as he did on Friday after the court’s ruling preserving the Deferred Action for Childhood Arrivals (DACA) program.

“The DACA will now hopefully go to the Supreme Court where it will be given a fair decision,” Trump told reporters.

Trump already has appointed two justices to the nine-member Supreme Court, solidifying its 5-4 conservative majority.

The 9th circuit has 16 judges who were appointed by Democratic presidents and seven who were named by Republican presidents. Democratic presidents tend to appoint more liberal jurists while Republican presidents favor more conservatives judges.

It is one of the series of powerful regional federal appeals courts that are one step below the Supreme Court. These circuit courts often provide the last word in a legal dispute because the Supreme Court hears only a limited number of cases.

The 9th Circuit hears appeals in federal cases spanning a huge region in terms of both geography and population, covering the states of Alaska, Arizona, California, Hawaii, Idaho, Montana, Nevada, Oregon and Washington.

Trump already has named two judges to the 9th Circuit, with six other vacancies waiting to be filled. Trump will not be able to create a conservative majority on the 9th Circuit, however, without additional vacancies caused when actively presiding judges retire.

Aided by fellow Republicans in the U.S. Senate, Trump has made it a top priority to rapidly appoint judges in a bid to make the federal judiciary more conservative.

Trump has suggested his policies do not get a fair shake in the 9th Circuit and has touted the idea of breaking up that court. Trump last year decried the 9th Circuit’s “ridiculous” ruling on the travel ban, and said that court has “a terrible record of being overturned” by the Supreme Court - an often-made charge that the 9th Circuit’s chief judge took issue with in congressional testimony.

(For a graphic showing Trump’s impact on federal appeals courts, click tmsnrt.rs/2PPsGtM )