WASHINGTON — Love her or hate her, Nancy Pelosi is a rare legend in her own time — a figure who is at once historic and still very relevant.

The highest-ranking woman in the history of American government, Pelosi has twice helped lead her caucus from the minority to the majority and is fairly regarded as the best congressional vote-counter of her generation.

But now, with the California congresswoman trying to return to the speakership, a small band of her Democratic colleagues would rather relegate her to the past than allow her to lead them again.

The fight is very real.

It's a battle consuming House Democrats in the wake of the midterm elections, and it is one that is wrapped up in the ideological, gender, racial and generational politics of a moment in which the party is both optimistic about its resurgence and terrified of the possibility that its gains will be washed away by President Donald Trump and the GOP in two years.

But it's also increasingly entangled in personal animus — the disdain that a handful of harsh Pelosi critics have for her and the rising frustration that many rank-and-file Democrats have with them for forcing the party into an ugly debate on the heels of its biggest House victory since the post-Watergate class of 1974.

Some in the party believe that Pelosi, who has demonstrated her ability as both a partisan warrior and backroom deal-maker, is the perfect leader at a precarious time for Democrats.

"No one has her legislative chops or wealth of experience," said Rep. Gerry Connolly, D-Va. "She knows how to exhort, inspire, cajole, intimidate and persuade. She never lost a vote on the floor as speaker. She worked tirelessly to bring us out of the wilderness. She has earned it."

Others see her potential promotion as a step backward — a message to the country that Democrats aren't agents of change — and a surefire attack point against newly elected freshmen in their first re-election bids.

"Last week, the American people sent a clear message that we need a new approach and new leaders in Congress," Rep. Tim Ryan, D-Ohio, who lost to Pelosi in a minority leader race two years ago, said Wednesday. "It’s time for us to listen."

Between returning incumbents and incoming freshmen, there are roughly two dozen Democrats who have publicly indicated they will or could vote against Pelosi. For some of the newcomers, distancing themselves from the California Democrat — who was a staple of Republican campaign ads and talking points across the country — was a matter of political survival.

The big question is how many members of the next Congress — like Ryan — truly want to stop Pelosi from taking the helm of the House in January and how many simply need to signal to voters back home that they raised an objection to her.

If politically safe House veterans like Ryan and fellow Rep. Seth Moulton, D-Mass., who are among the ringleaders of the anti-Pelosi faction, choose not to back Pelosi on the floor, that puts more pressure on freshmen who just won tough districts to cast potentially perilous votes that help her win.

That's a strike against the rebel crowd for Democrats who would prefer to see Pelosi win while allowing as many freshmen as possible to not vote for her.

The coming days will be a test of Pelosi's ability to maneuver through the thicket of Democratic Caucus personalities and House rules, a point of strength for her in the past but a challenge at a time when the eyes of her party, and the nation, will be fixed on what her colleagues decide.

She and her allies have been ramping up the campaign to secure votes — several union, interest groups and Democratic Party luminaries put out statements announcing their support for her — a clear indication that she knows she has to work hard to win.

At the same time, an emboldened faction of her harshest critics has been promising that it can deliver the votes to deny her the speakership.

Rep. Marcia Fudge, D-Ohio, said Wednesday that she's considering a bid against Pelosi — giving the recalcitrants a potential alternative.

"When you look at the people who support this party the most, they are women and African Americans and especially African American women," Fudge, who is black, told Cleveland.com. "We keep talking about diversity, but there is nothing diverse about the top of our ticket. We have to not just talk the talk, but walk the walk."

After meeting with Pelosi Friday, Fudge said that she would make a decision after Thanksgiving and would weigh the "enormity" of the job — the long hours of campaigning and fundraising for the party's candidates — as part of her calculus.

For Pelosi, the first step is a vote in the Democratic Caucus, which is scheduled for the week after Thanksgiving. In short, Pelosi will be running to be the party's pick for speaker when the whole House — Democrats and Republicans — vote on the post in January.

There's no question that she has the backing of a majority of her caucus. In fact, right now, she has no competition from within the party at all.

Democratic aides have said it's possible that if she doesn't draw a challenge, they may hold an up or down vote on her in caucus and publicize the vote tallies.

"Certainly a possibility," a Democratic aide who declined to be identified because he was not authorized to speak publicly about internal deliberations told NBC over email. "Not clear yet."

That way, the "no" voters could point to their effort to oppose her. For the same reason, it makes sense that her critics might not actually field a challenger — because it would give an easy out to those who promised to oppose her without forcing them to vote against her on the floor.

The second, tougher step is the full House floor vote. To win that, Pelosi needs a majority of the members who vote — Republicans and Democrats. Typically, that would mean at least 218 of the 435 House members. But, of course, there's a wrinkle: Any members who vote "present" are not counted.

If, for example, there are 232 Democrats and 203 House Republicans — some races are still being decided — Pelosi could defeat incoming House Minority Leader Kevin McCarthy 204-203 with 28 Democrats voting "present."

But each vote for another lawmaker — not her or McCarthy — would make her path harder. Using the same hypothetical partisan split, it would take just 15 Democratic votes for lawmakers other than Pelosi or McCarthy to prevent her from winning a majority and force a second round of balloting on the floor.

The House keeps voting until someone wins a majority.

Already, Pelosi allies have reached out to incoming freshmen who said they wouldn't vote for her to ask that they vote "present," Democratic sources told NBC News.

If Pelosi is able to navigate the labyrinth, it will be proof that her skills at the inside game aren't just the stuff of legend. If she fails, it will be the first time that a minority leader who sought and won re-election at home failed to win the speakership after leading his or her party to the House majority.

That's one bit of history Pelosi would like to leave intact.