Read: James Mattis’s final protest against the president

The Mattis resignation has sparked panic in Washington, but the shutdown is, for now, the more urgent crisis. Funding for large portions of the government runs out on Friday. Although Trump bragged last week that he’d be “proud” to shut down the government over Democrats’ refusal to fund his border wall, Congress and the White House on Thursday seemed headed for a quiet stopgap funding measure to keep the government running until February.

But then Trump was seemingly bullied into blowing up the compromise by harsh criticism from his allies in the right-wing media, including Rush Limbaugh, Laura Ingraham, and Breitbart News. The White House announced that he would not sign any bill without wall funding. Neither Trump nor anyone else has any viable plan for bridging the gap, other than hoping that nine Democrats in the Senate will flip and vote for a wall their party despises. Although Trump tweeted Friday morning that “if enough Dems don’t vote, it will be a Democrat Shutdown!” they have little incentive to go along with him, because he has already publicly boasted that he would take the blame.

As the government braced for a closure that could drag into the Christmas holiday, Mattis’s exit arrived unexpectedly. Though the defense secretary, a retired four-star general, had disagreed with Trump repeatedly in the past, his resignation was an astonishing rebuke of the president. Cabinet members seldom resign in protest, and his letter avoided praise for Trump while delivering harsh implicit criticism of the president’s disdain for alliances and affection for authoritarianism.

Mattis’s exit horrified not only Democrats and anti-Trump conservatives, but also some of the president’s closest allies. In what passes for a hair-on-fire reaction by Mitch McConnell standards, the Senate majority leader said, “I am particularly distressed that he is resigning due to sharp differences with the president on these and other key aspects of America’s global leadership.”

Mattis was frequently reckoned to be a crucial brake on Trump’s worst impulses, protecting him from decisions even more disastrous than the ones he made. Whether that was true will likely become clear soon. Yet Mattis resigned because he was unable to dissuade Trump from announcing a precipitous withdrawal of American troops from Syria (in which the president falsely claimed that ISIS was defeated) or stop the president from an expected announcement of a pullout from Afghanistan. These decisions are in keeping with Trump’s campaign promises, but the hasty, nonstrategic methods of withdrawal rattled even critics of both military engagements.

Hawks were even more upset. Senator Lindsey Graham, the South Carolina Republican, lashed out at the announcements and questioned Trump’s choice. “The only reason they’re not dancing in the aisles in Tehran and ISIS camps is they don’t believe in dancing,” he said. While Graham has always favored military intervention, his criticism is notable because he has become a leading stroker of the president’s ego. The matter threatened to drive a spike between Graham and Trump, with the White House adviser Stephen Miller lambasting the senator on CNN Thursday evening.