Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

With two out of the three branches of government now in the hands of Donald Trump and his Republican allies, civil libertarians are counting on the courts to block what they believe are grave threats to U.S. democracy.

Long before Trump signed executive orders to build a border wall, crack down on "sanctuary cities" and bar Syrian refugees, the American Civil Liberties Union and like-minded groups were preparing to sue him.

They expect to spending a lot of time in court, as Trump reportedly plans further executive actions to reinstate the CIA’s “Black Sites" for terror suspects, restrict Muslim immigration, and more.

“It's actually hard to identify an area where we're working that is not facing some threat from the incoming Trump administration,” said David Cole, the group’s national legal director.

Bolstered by millions of dollars in new donations and hundreds of offers of pro bono help from attorneys since the November election, the ACLU has been busy retooling itself for wartime. It has expanded its legal, advocacy, and communications teams and beefed up its Washington, D.C. office under an aggressive new director hired from the office of former Sen. Harry Reid.

Three days after the election, the ACLU took out a full page ad in the New York Times threatening Trump with litigation, while the cover of its magazine featured a portrait of the new president and the words, in giant red letters, “See you in court.”

Related: Trump Signs Orders Aimed at Cracking Down on Illegal Immigration

Cole is confident the legal system will be the backstop of civil rights, noting that the same Supreme Court that installed George W. Bush in the White House turned around and rebuked him on the first four cases that tested some of the administration's post-September 11 anti-terror policies.

“The whole idea of the separation of powers is to ensure that each of the branches has a self-interest in checking each other,” said Cole. “Judges tend to be establishment figures, whether they're on the left or the right. Donald Trump is not an establishment figure.”

But with Trump poised to appoint a new justice soon to a court that has been hobbling along with only eight members for nearly a year, there are many fights ahead.

The threat that the ACLU and other groups have been preparing came into view Wednesday when Trump signed executive orders cracking down on undocumented immigration.

The Morning Rundown Get a head start on the morning's top stories. This site is protected by recaptcha

Related: Draft Order Eyes Return to Overseas CIA Prisons

One order threatens to strip federal funding to so-called sanctuary cities, where local law enforcement declines to arrest and detain undocumented immigrants on behalf of federal authorities.

Opponents were ready. “Cutting off funds for cities that refuse destructive deportation programs is unconstitutional. See you in court,” tweeted Kevin de Leόn, the Democratic leader of the state Senate in California, which recently retained former U.S. Attorney General Eric Holder.

Throughout the day, Democratic mayors of major cities echoed the calls for litigation, eager to show their opposition to Trump and support immigrants.

In the country’s other major blue state, New York Attorney General Eric Schneiderman recently created legal guidance to help sanctuary cities in a potential fight with Washington. “We've already begun to prepare for things that we think are coming,” Schneiderman said in an interview.

Schneiderman, whose office investigated Trump University, said he’s willing to go to court both if the administration goes too far in some places and if it doesn’t go far enough to enforce laws it may disagree with.

“We are prepared to go to court to make sure these agencies do their jobs, whether it's enforcing environmental laws, enforcing labor laws,” said Schneiderman.

He was one of 19 city and state leaders who warned Trump there would be "more litigation" if he dismantles the Obama administration's Clean Power plan to cub greenhouse gas emissions, which itself grew out of a lawsuit against the Environmental Protection Agency.

Karen Tumlin, the legal director of the National Immigration Law Center, said her group has been a frenzy of activity since the election doing legal research, bringing on new staffers, and preparing memos as they tried anticipated waiting to see how Trump would govern.

In addition to the crackdown on sanctuary cities and undocumented immigrants in general, the group is worried about new restrictions on refugees. "Folks are prepared to bring their best thinking and swift action to anything that violates the law,” said Tumlin.

A whole ecosystem of lawyers and advocates sprung up during the Bush administration, and they are now way ahead of where they were in early years of the War on Terror.

“In 2001, it was basically just Michael Ratner running around waving a writ of habeas corpus. We couldn't find even find local legal counsel in some cases,” said Baher Azmy, the legal director of the Center for Constitutional Rights, referring to the group’s late president, who died last year. “Now, as a result of the Bush Administration, there's a whole well-resourced consortium of organizations geared up and ready to fight.”

Azmy also noted that courts today, 16 years removed from 9/11, may be less amenable to the government’s arguments that restrictive programs on, say Muslims entering the United States, are necessary.

“Everyone feels like democracy is on the line and we're not going to down without fighting,” Azmy added.

Under the Bush administration, human rights abuses happened in secret and were often only uncovered years after they began through investigative reporting. Trump, on the other hand, campaigned on reinstating torture, expanding the prison at Guantanamo Bay, and banning Muslim immigration.

“The differences here is that the proposals have been made public, even during the campaign,” said Maria McFarland, the co-director of the U.S. program at Human Rights Watch.

That’s given advocates time to prepare and have at least a rough idea of what they're up against, though it’s still unclear how Trump’s campaign rhetoric will translate to policy.

One group that grew out of the Bush era is Muslim Advocates, which in 2015 was part of a team that won a major federal lawsuit against the New York City Police Department’s surveillance of Muslims.

“Literally from the day after the election we went into gear and started putting together our battle plan,” said Farhana Khera, Muslim Advocates’ executive director. “This is probably the biggest fight that any of us have seen in our adult lives.”

Of immediate concern to Khera is a proposed executive order to dramatically restrict immigration from countries deemed prone to terror, most of which are Muslim. “We think it's a step towards the complete Muslim ban that he promised during his campaign,” she said.

Even as the battle is playing out in public, it’s happening on so many more fronts than during the Bush years, when the main victims were foreigners in far off countries.

“There are so many threats coming now, including things that weren't happening during the Bush administration, that people could be spread pretty thin,” said Katherine Hawkins senior counsel at the Constitution Project, which advocates on civil liberty issues.

And she noted that the government's surveillance capacity has expanded dramatically since September 11.

“Just because something is clearly illegal doesn’t mean it can't do a lot of harm. These laws don't enforce themselves,” said Hawkins. “You have to find a lawyer to file a case and you can't do that if you're disappeared somewhere.”