While President Trump’s travel ban threw American airports into chaos last weekend, Bob Ferguson, the attorney general of Washington State, was biding his time on an airplane.

On his way home from a conference of Democratic attorneys general in Florida, Mr. Ferguson landed a week ago in the center of a political and legal firestorm. Seattle-Tacoma International Airport was in disarray, with protests massing. Gov. Jay Inslee, a fellow Democrat, had sent word to the attorney general’s staff that he wanted to mount a battering-ram attack on the president’s decree.

Within two days, Mr. Ferguson had become a leading combatant in a battle with the president of the United States, filing a dramatic challenge to Mr. Trump’s travel ban that yielded a ruling from a federal judge on Friday freezing the order’s implementation.

A genial 51-year-old with an earnest demeanor, Mr. Ferguson cuts an unlikely figure as an antagonist for the most pugilistic president in modern times. He is seen in the state less as a chest-thumping showman than as a former member of the King County Council with a wonky sensibility and an eager manner.

But Mr. Ferguson, by his own account and the description of his associates, was incensed and offended by Mr. Trump’s sweeping immigration restrictions. And having landed in Seattle on the first full day the ban was in effect — while demonstrations grew across the country — he went home to greet his family and then went to work devising a plan to cripple Mr. Trump’s new policy.

In an interview, Mr. Ferguson said he had concluded from the start that Mr. Trump’s order was “unlawful and unconstitutional,” and that any appropriate response would have to aim at neutering it entirely. Eschewing the approach of other Democratic-leaning states, which have challenged Mr. Trump’s order by highlighting the claims of individual plaintiffs, Mr. Ferguson and his office opted to draft a complaint arguing that the ban would cause drastic damage to Washington State as a whole.

Mr. Ferguson said that the state solicitor general, Noah Purcell, a former Supreme Court clerk for David H. Souter, had suggested last weekend that the state enlist major private companies as allies. And so the attorney general spoke by telephone with a host of executives, including the corporate counsels of Expedia and Amazon, who agreed to supply forceful declarations for the state’s suit, describing the damage that the White House order could inflict.

Mr. Ferguson said he had recognized at the time that this was a potentially risky approach, seeking a more sweeping victory with a comparatively untested legal strategy.

But Mr. Ferguson, a former state chess champion, explained in precise language that he had decided it was a gamble worth taking.

“From my standpoint there is risk in everything, but I am someone who believes in calculated risk,” Mr. Ferguson said in the interview. “One just needs to be comfortable with that. And when it comes to the constitutional rights of my people, the people I represent, I’m prepared to take a calculated risk on their behalf.”

Mr. Inslee, also in an interview, said he strongly backed Mr. Ferguson’s approach, viewing Mr. Trump’s order as a unique threat to their state’s economy, which depends heavily on international trade, and to the state’s diverse population. In his view, the governor said, the state was right to make “any plausible claim” to take down the order.

Few other states adopted such a daring strategy. Mr. Ferguson said he had invited other Democratic attorneys general to join in his lawsuit, finding only one taker so far: Lori Swanson of Minnesota. Mr. Ferguson said there were other states still weighing whether to join him.

Mr. Inslee described the Friday ruling as a special kind of victory for Washington State, which draws relatively little attention in national politics but tends to race ahead of national trends on social issues.

“It’s part of our nature and history,” Mr. Inslee said. “This is the first time this administration has been reined in.”