Music legend Barbra Streisand retweeted a list of Rep. Nancy Pelosi’s biggest legislative achievements. Film director Rob Reiner called her “the smartest, toughest strategic thinker in our party.” And tennis champ Martina Navratilova wondered aloud why Pelosi’s job was at risk but her Senate counterpart’s position was in no such trouble.

“Go figure,” Navratilova tweeted. “A man loses and keeps his place, a woman wins and gets booted?!?”

While congressional leadership fights have historically revolved around insular matters such as committee assignments and rules changes, the battle over who will lead the newly empowered House Democrats has exploded into a national political campaign.

At stake is not merely the House speakership, a job second in line to the presidency, but who will emerge as the country’s most high-profile counterpoint to President Trump — who will set the strategy for investigating him, who will lead the opposition to his agenda, and who will be the face of the Democratic Party ahead of the 2020 campaign.

The country’s biggest unions, arguing that Pelosi is the best equipped to take on Trump, have lobbied Democrats to back her. Top donors have placed calls to lean on undecided members. Celebrities have weighed in as well, and prominent liberal activists have openly discussed fomenting primary challenges in the next campaign against the leaders of the anti-Pelosi opposition.

The battle lines have been drawn around identity, race and gender — issues that dominated this year’s midterm elections.

Some in the pro-Pelosi camp have presented her speakership bid as the next logical step in the #MeToo movement, particularly after an election in which a record number of women ran for and won seats in Congress, and with many activists still angry over the confirmation of Supreme Court Justice Brett M. Kavanaugh, who denied allegations of sexual misconduct.

“There is some residual anger being worked out in the speakership race as a result,” said Shannon Coulter, who co-founded a large boycott of Trump-related businesses known as the Grab Your Wallet campaign, and has been advocating for Pelosi.

A potential challenge to Pelosi from an African American lawmaker, Rep. Marcia L. Fudge (D-Ohio), threatens to further divide Democrats along racial lines as Pelosi has moved quickly to solidify her support among prominent members of the Congressional Black Caucus.

Already the first woman to serve as speaker, Pelosi has said emphatically she will make history again and become the first lawmaker to reclaim the gavel since 1955 when the full House votes Jan. 3.

“I have overwhelming support in my caucus to be speaker of the House,” she asserted this past week as Democrats rolled up more wins to add to their majority.

The 78-year-old California congresswoman has rejected calls for a new generation of leaders after her furious campaigning, more than $130 million in fundraising and focused message of protecting the health-care law that she helped pass in 2010 delivered a Democratic majority.

Trump, who during the campaign described a Democratic-led House in apocalyptic terms, said Saturday that Pelosi earned the right to be speaker and offered help in persuading Republicans to back her.

“If she needs any votes, if she asks me, I will give her the votes to put her over the top,” Trump told reporters at the White House.

It is unlikely many Republicans would vote for the one Democrat that they have portrayed as a scary liberal in thousands of campaign ads over the years — and open themselves to a primary challenge. But in a tweet Saturday, Trump referenced Rep. Tom Reed (N.Y.), a Republican who helps lead the bipartisan Problem Solvers Caucus. Reed has suggested he could vote for Pelosi as he works with moderate Democrats on ambitious rules changes.

Absolutely unnecessary, Pelosi has said, telling reporters this past week that she would “never, never, never” need GOP votes. Her spokesman, Drew Hammill, said Saturday, “Leader Pelosi will win the speakership with Democratic votes.”

As opponents vowed to defeat her on the House floor, Pelosi pushed ahead with an intense operation to secure the votes, marshaling support from across the left that highlighted her skills and contributions to the party’s midterm victories.

But even as backing Pelosi became a cause celebre for prominent Democrats, the contest seemed to deepen divisions within the party’s ranks that threatened to split Democrats after their resounding win.

“I’m more than exasperated. I’m totally furious,” longtime Pelosi ally Rep. Jan Schakowsky (D-Ill.) said of the opposition. “To have a small rump group that is determined only, so far that I can see, to deprive the majority choice of the caucus, Nancy Pelosi, to be speaker is simply outrageous.”

The first test for Pelosi is Nov. 28, when Democrats choose their candidates. She is expected to win easily in the simple majority vote. After that, the math is tight. Twenty current and incoming Democrats say they will not support her for speaker, exceeding about 15 votes she can lose when the full House votes. By week’s end, a few opponents seemed to be wavering after one-on-one sessions with Pelosi.

Her Democratic critics say it’s time to choose a new leader after 16 years with Pelosi, citing the need for fresh faces and her unpopularity in more-conservative districts that Democrats must win to keep their majority.

But the anti-Pelosi faction has drawn criticism for not yet identifying all its members, failing to produce an alternative and even suggesting many women could do the extraordinarily difficult job.

“There may be a floor fight” in January, said Rep. Tim Ryan (D-Ohio), a leader of the opposition. “A lot of names are going to get tossed around.”

Ryan raised hackles by telling reporters this past week that there are “plenty of really competent females” that could replace Pelosi.

“If she were a man I don’t know whether we’d be talking about, ‘Is a woman going to be competent to do this?’ ” said Rep. Doris Matsui (D-Calif.), a Pelosi supporter. “That frosts me a bit here.”

Pelosi has said that if Hillary Clinton had beaten Trump, she would have stepped aside, knowing a woman would be at the table for negotiations with top congressional leaders, and a Democratic president would protect the Affordable Care Act. In an echo of Clinton’s experience in 2016, Pelosi has had to work to win over the younger generation of women, as many of the newly elected female lawmakers did not immediately back the trailblazer.

Though support had gradually emerged for her bid, the pro-Pelosi juggernaut did not reveal itself in full force until this past week. In the course of a few days, Pelosi received support from more than two dozen groups across the left, including labor unions, women’s organizations, the LGBT community and grass-roots activists.

The campaign eventually took on a life of its own among well-known names, such as Streisand, Reiner and Navratilova.

Supporters have cited the need for a speaker who can immediately stand up to Trump, spell out the Democrats’ agenda and score legislative wins for the party before the next campaign.

“We need somebody who’s really experienced, who’s not going to back down, who’s not going to have a learning curve,” said Rep. Pramila Jayapal (D-Wash.), who is likely to co-chair the House Progressive Caucus. “We have very little time. . . . It’s a six-month cycle to really get something done and then everything moves to 2020.”

But opponents dismissed the notion that Pelosi is the only House Democrat who has the strength and experience to take on Trump.

“That’s pretty insulting to the rest of the Democratic members who have been elected by their communities,” said Rep. Brian Higgins (D-N.Y.). “There are plenty of people who could hold their own at that table.”

Some allies of Pelosi have dismissed opponents such as Ryan and Rep. Seth Moulton (D-Mass.) with the hashtag #FiveWhite­Guys.

Ryan declined to comment on the slogan on Friday and said that Fudge remains his choice for speaker. Fudge met with Pelosi on Friday and said she will make a decision on a speaker’s bid after Thanksgiving.

“I don’t think anybody would be interested in blocking the first African American woman to be speaker,” Ryan told reporters.

But this opposition to the leading candidate is already generating talk of primary challenges in 2020. Amy Siskind, a liberal activist and author who promotes candidates to her 326,000 Twitter followers, vowed to raise money and recruit women to oppose anti-Pelosi agitators. She said she has told candidates she supported in 2018 that they should back Pelosi.

“If you want our support in 2020, if you want help from beyond your district, if you want national attention on your race, this is not the hill to die on,” she said.

Pelosi’s position appeared to have grown stronger by Friday night.

Advisers to Pelosi and Rep. Steny H. Hoyer (D-Md.), who is running for majority leader, privately voiced greater concern earlier in the week to their allies in lobbying shops and special interest groups, according to two sources familiar with the leadership offices.

But by late Thursday, they felt much more confident, saying they had identified the field of potential dissidents — about 20 or so Democrats — and were drawing up a battle plan to sway each one, the people said.

If a potential “no” vote worked on climate policy, for example, Pelosi’s advisers had environmental activists, or even former vice president Al Gore, reaching out to seek support for Pelosi, they said. The inside game also included several dozen one-on-one meetings in Pelosi’s leadership office Thursday and Friday, particularly with incoming freshmen, according to advisers.

When Pelosi convened a meeting of her whips Thursday, 43 Democrats were on hand to get marching orders about which votes needed to be flipped. The House minority leader carries a detailed whip list in her pocket and is constantly updating it, said one Democratic aide.

Paul Kane contributed to this report.