GOFFSTOWN, N.H. — In his opening remarks at the Democratic presidential debate on Saturday, Senator Bernie Sanders railed against “establishment politics and establishment economics” and then the nation’s “rigged economy.” He moved on to the “corrupt” campaign finance system, then the “planetary crisis of climate change.” Only after that did he say he wanted to destroy the Islamic State.

It was a litany of priorities that made good sense when Mr. Sanders announced his presidential bid in April. But after the terrorist attacks in Paris and San Bernardino, Calif., he made fighting terrorism sound like an afterthought.

These are challenging times for Mr. Sanders as the chief opponent to Hillary Clinton for the Democratic nomination. His progressive political message, so popular with liberals for much of 2015, now seems lost in a fog of fear. Americans are more anxious about terrorism than income inequality. They want the government to target the Islamic State more than Wall Street executives and health insurers. All of this plays to Mrs. Clinton’s strengths — not only as a hawkish former secretary of state but also as a savvy politician who follows the public mood. After months of pivoting to the left on domestic issues to compete with Mr. Sanders for her party’s base, she is now talking about security and safety far more than Mr. Sanders — and solidifying her lead in opinion polls.