When Washington state Attorney General Bob Ferguson arrived in Seattle last Saturday after a trip to Florida, public outrage over the immigration order issued the previous day by President Donald Trump was quickly growing. He went home, greeted his family and then went to work.

By late Monday afternoon, just minutes before the court closed for the day, Ferguson, a Democrat, and his team of lawyers were ready to file the first state lawsuit seeking to block the order. On Friday, they won a dramatic courtroom victory when U.S. District Judge James Robart put on hold the travel ban for refugees and citizens of seven mainly Muslim countries.

The lawsuit emerged out of a chaotic 48-hour period in which the need for immediate action held sway over the kind of carefully thought-out strategizing that usually leads up to a major legal complaint being filed, according to Ferguson and other attorneys involved in actions against the order.

"We knew we had one shot," Ferguson said in an interview, in reference to the bid for a temporary restraining that would immediately overturn Trump's executive order.

The lawsuit is one of several now filed against the executive order around the United States, but it was the first case leading to a broad decision that applies nationwide.

The fight over the immigration order is just the first of what is likely to be a series of court battles between Democratic attorneys general, the top legal officers in liberal-leaning states, and the administration. Several attorneys general have already said they expect to sue Trump on various issues if he oversteps his authority, including on the environment and consumer protection.

President Trump on Saturday ridiculed Judge Robart, a George W. Bush appointee, and his decision. The Justice Department filed a formal appeal.

The Washington state lawyers worked around the clock last Saturday and Sunday against the backdrop of turbulent scenes at U.S. airports, where immigrants were detained by federal officials unprepared to implement the president's directive.

There was little time to coordinate with other states, though ultimately one other state, Minnesota, joined the effort. Additional states, including Virginia, New York and Hawaii, have filed their own lawsuits or sought to intervene in cases brought by individuals affected by the ban.

State attorneys general did not collectively decide to let Washington file first for any strategic advantage, Ferguson said. Rather, Washington was able most quickly to marshal evidence of the harm Trump's order caused to the state, which is crucial to establish legal standing.

Ferguson called the general counsels at major Washington employers Amazon.com Inc. and Expedia Inc. for their support. The companies eventually filed sworn statements in court saying the ban hurt their businesses.

The state lawyers also gathered information on the harm to state residents and institutions such as the university system, which the judge appeared to find persuasive.

TURNING THE TABLES

The legal assault on the order has involved Ferguson and other Democratic lawyers taking a leaf from the play-book followed by Republican states that successfully challenged actions taken by Trump's predecessor, former President Barack Obama.

Washington state's claims rely in part on the same legal arguments that Texas and 25 other Republican-led states made when they challenged Obama's November 2014 plan to protect up to four million immigrants from deportation. In that case, the Republican states argued that Obama overstepped his constitutional powers by infringing upon the authority of Congress.

Washington and other states say Trump has violated the Constitution too, albeit on different grounds. They say he has violated protections against discrimination on the basis of religion by targeting Muslims. The state has a responsibility to protect the "health, safety, and well-being" of all its residents, the lawsuit said.

In the 2014 case, Texas, like Washington state in the Trump case, asked for a nationwide injunction.

Where the fight against Trump's order differs from the Texas challenge to Obama is that various lawsuits have been filed around the country by states and civil rights groups. The Texas case was a single lawsuit that the other states joined.

ACLU lawyer Lee Gelernt said there was little time to talk strategy among the many states and advocacy groups opposing the order, as would normally happen. "It's moving too quickly,” he said.

That sense of urgency was all too clear to Washington state lawyers on Monday as they feverishly gathered the required documents to file with the lawsuit, including the motion for a temporary restraining order.

Unlike other court papers filed electronically, a paper copy of that motion had to be delivered to the clerk's office in person. So Noah Purcell, the solicitor general, led a race to the Seattle courthouse with others from the office just as the building was about to close. They pulled up to the courthouse, jumped out of the car and ran up the steps to the doors before they were locked. They arrived just in time.