Hillary Clinton and Bernie Sanders meet here Sunday night for the final Democratic debate before the Iowa caucuses and the New Hampshire primary and, to the surprise of many in her party, it is the former secretary of state who has much to prove.

She arrives here in the middle of a rocky stretch, all of a sudden on the wrong side of a new narrative that suggests Sanders is surging and she is weakening, facing possible defeat in the first two contests of the year.

The Vermont senator continues to lead the polls in New Hampshire, and now he has closed the gap in Iowa, the state where Clinton’s campaign fell off the tracks eight years ago. For Clinton, it wasn’t supposed to be this way against a septuagenarian, self-identified democratic socialist who began his campaign with no national profile and no financial network.

Clinton’s allies have tried to have it both ways. They have claimed that they knew the race would always be competitive (which, in fairness, her campaign leaders said from the very beginning). But they are firing back at Sanders on guns, health care and other things in a way that underscores their concern about the dangers of a protracted nomination contest.

How else to explain the stepped-up rhetoric from the candidate or the sharp and distorted attack launched this week by Chelsea Clinton? Clinton’s daughter said that Sanders wants to eliminate Obamacare, the children’s health-care program and Medicare, which is not his position. He advocates a single-payer system.

Clinton began this campaign as the prohibitive favorite to win the nomination — even more so than she was eight years ago — which she eventually lost to President Obama. In a hollowed-out Democratic Party, the field of her potential rivals this time paled in comparison to that of 2008. At the same time, the vast Clinton fundraising network promised plentiful resources.

Confident of her strength and of the eventual outcome, the Democratic establishment began to consolidate around her long before she even formed her campaign committee. And yet, almost everything about the campaign environment as it has developed has made things more difficult for her.

She is the embodiment of the Washington political class in a year of rising antiestablishment anger. She struggles to project authenticity at a time when voters hunger for that quality in their candidates. She has a lengthy résumé in public life at a time when many voters seem to have devalued experience in government. She symbolizes continuity when many voters are demanding reform.

Clinton presides over a large campaign operation built on models of successful campaigns from past years. Sanders and Donald Trump have found success with non-traditional campaigns. Trump has redefined political communication. Sanders, who has minimal access to major contributors, has fueled his candidacy through grass-roots energy and a record number of contributions from small donors.

It seemed unimaginable that a Clinton, particularly a Clinton who could become the first woman U.S. president in history, could be overshadowed in a political campaign this year and yet that’s currently the case. Trump and Trumpism loom over the entire country. His candidacy is the talk everywhere, for better and worse.

Sanders also creates his own energy force with an unabashedly liberal, big-government agenda that brings cheers from the progressive wing of the party. He has tapped into pent-up frustration on the left that has proven to be a potent force.

Little noticed in this week’s Des Moines Register-Bloomberg Politics Iowa poll was this finding: a remarkable 43 percent of likely Democratic caucus participants describe themselves as socialists, including 58 percent of Sanders’s supporters and about a third of Clinton’s.

Ann Selzer, who conducted the poll, said that, among those who identify themselves as socialists, Sanders “leads by a lot.” It is an illustration of one of the unexpected problems Clinton has encountered.

Meanwhile, Clinton soldiers on. She is still seen as the likelier of the two to win the Democratic nomination, even if she were to lose Iowa and New Hampshire. Sanders’s weakness among African American voters offers her protection when the campaign heads here later next month. But losses in Iowa and New Hampshire could have unpredictable effects. For Clinton, it would be far better not to test the proposition.

Winning Iowa remains paramount at this moment, and there is still confidence among Clinton loyalists that the ground operation there is sturdy enough to withstand the challenge from Sanders. But shoring up operations in other states is a priority as well, in the event of a double loss.

One thing that hampers Clinton at this point is the lack of excitement for her candidacy, even among Democrats who actually support her. For whatever reason, she has yet to build broader enthusiasm. She rouses audiences with attacks on Republicans, though that is not difficult, and she has policy plans aplenty. But Democrats see her as still struggling to encapsulate her message into something that is crisp and compelling.

Taking on Sanders is not as easy as it might seem. Her advisers see him as vulnerable on the issue of guns. The attacks on health care require a deeper debate about the details of her policy vs. what she says are the lack of details about his. That’s a debate not easily reduced to sound bites.

One of her most potent potential attacks on Sanders is perhaps the most difficult of all to make directly, which is to argue that he can’t win a general election because he’s too far left at a moment when some polls suggest otherwise and the base is responding to his message.

Her big worry is that, the longer the nomination battle continues, the more it could deplete her resources and jeopardize her chances of prevailing in November. But Sanders is enormously popular among Democrats right now for what he is articulating and the way he is campaigning. And he has the resources to keep going.

Clinton was derailed eight years ago by a young and fresh politician who captured the moment and the imagination of voters. She has run into something quite different in this campaign, though no less unexpected. Sunday’s debate will offer clues as to how well she is responding.