Last may, Washington Post’s James Hohmann noted “an uncovered dynamic” that helped explain the GOP’s failure to repeal Obamacare. Three current Democratic House members had opposed the Affordable Care Act when it first passed. Twelve Democratic House members represent districts that Donald Trump won. Yet none voted for repeal. The “uncovered dynamic,” Hohmann suggested, was Nancy Pelosi’s skill at keeping her party in line.

She’s been keeping it in line for more than a decade. In 2005, George W. Bush launched his second presidential term with an aggressive push to partially privatize Social Security. For nine months, Republicans demanded that Democrats admit the retirement system was in crisis and offer their own program to change it. Pelosi refused. Democratic members of Congress hosted more than 1,000 town-hall meetings to rally opposition to privatization. That fall, Republicans backed down, and Bush’s second term never recovered.

In 2009, Pelosi persuaded deficit-wary Blue Dog Democrats to back Barack Obama’s stimulus package, and it passed without a single Republican vote. The following year, when Rahm Emanuel, then the White House chief of staff, suggested scaling back health-care reform after the Democrats’ surprise Senate loss in Massachusetts, Pelosi insisted that Obama maintain his goal of universal coverage. She enraged her pro-choice allies by allowing a vote on an amendment prohibiting women insured through the law’s health-care exchanges from receiving government-subsidized abortions. But that gave antiabortion Democrats cover to support the bill, which passed with nary a Republican vote.

These victories led Thomas Mann, who studies Congress at the Brookings Institution, to call Pelosi the “strongest and most effective speaker of modern times.” And even after being relegated to minority leader when Republicans took the House in 2010, she kept winning legislative fights. In the summer of 2015, the American Israel Public Affairs Committee and the Republican Party launched a mammoth lobbying campaign to kill Obama’s nuclear agreement with Iran. Pelosi quickly secured the votes to prevent Republicans from overturning the agreement, thus checkmating the deal’s foes.

In addition to being a masterful legislative tactician, the 77-year-old Pelosi is, in Politico’s words, “the most successful nonpresidential political fundraiser in U.S. history.” Yet many of her colleagues want her gone. In November 2016, almost a third of House Democrats voted to depose her as leader. Another coup attempt erupted last summer. Why so much discontent with a woman who has proved so good at her job? Maybe because many Democrats think Pelosi’s unpopularity undermines their chances of winning back the House. Why is she so unpopular? Because powerful women politicians usually are. Therein lies the tragedy. Nancy Pelosi does her job about as well as anyone could. But because she’s a woman, she may not be doing it well enough.

Within days of Pelosi’s ascension to House minority leader, in 2003, back when nearly 60 percent of Americans still had no idea who she was, the Republican Party featured her visage—“garish and twisted,” in the words of a magazine article at the time—in an ad against a Democrat running for Congress in Louisiana. The GOP has been using her as a scarecrow ever since. Before the 2010 midterms, the National Republican Congressional Committee cited Pelosi in an astonishing 70 percent of its ads—far more than the percentage that cited Obama. And for good reason: Internal Republican polling showed that Pelosi was far less popular than the president. After Democrats lost their House majority that fall, Congressman Allen Boyd of Florida, whose reelection bid failed, called hers “the face that defeated us in this last election.”

In the run-up to the 2012 elections, according to the Wesleyan Media Project, Republicans invoked Pelosi in television ads seven times as often as they invoked the Senate’s Democratic leader, Harry Reid. Four years after that, in the run-up to 2016, they invoked her three times as often.

In the Trump era, as Republican vulnerability has mounted, the GOP has targeted Pelosi yet again. Last summer, when the Democrat Jon Ossoff showed surprising strength in a special election for a House seat in Georgia, Republicans responded with millions of dollars in ads tying him to Pelosi. “Say No to Pelosi’s Yes Man,” a GOP commercial instructed. One piece of Republican mail depicted a laughing Pelosi maneuvering Ossoff like a marionette alongside the words “Now She’s in Control.” Another featured Pelosi ripping off an Ossoff mask. When the journalist Michael Tracey traveled through Montana before it held a special House election last May, he was, he wrote on CNBC’s website, “struck by the frequency with which folks cited aversion to Pelosi as the reason why they’d backed the Republican.”

The Democrats who want Pelosi gone don’t deny her talent. But they say her unpopularity is too heavy a load to bear. “The Republican playbook for the past four election cycles has been very focused, very clear,” Representative Kathleen Rice, a Democrat from New York, insisted after Ossoff’s defeat. “It’s been an attack on our leader. Is it fair? No. Are the attacks accurate? No. But guess what? They work.” Nonpartisan observers agree. As David Wasserman, an editor of “The Cook Political Report,” tweeted after the Georgia loss, “It’s just extremely difficult for Ds to argue benefits of Nancy Pelosi’s fundraising skills still outweigh cost of her presence in GOP ads.”

Not everyone agrees that Pelosi’s unpopularity is a function of gender. Some observers note that her Republican counterpart, Speaker Paul Ryan, is unpopular too: According to HuffPost’s poll aggregator, Americans disapprove of both Ryan and Pelosi by 20 percentage points. But Ryan’s unpopularity tracks his party’s, which Americans disapprove of by 23 points—whereas Pelosi’s disapproval margin is almost twice that of the Democratic Party as a whole. Others chalk up Pelosi’s image problems to her ideology (liberal) and home base (San Francisco). But Senate Minority Leader Charles Schumer, a liberal from Brooklyn, has a disapproval margin half as large as hers.

One might think grassroots Democratic enthusiasm for Pelosi would offset her lack of appeal among Republicans and independents. The party, after all, is moving left, where Pelosi has been all along. She opposed Bill Clinton’s attempt to allow China into the World Trade Organization; she opposed Don’t Ask, Don’t Tell, his policy that prevented LGBT Americans from serving openly in the military; she opposed the Iraq War when most of the House Democratic leadership, and almost every Democratic senator running for president, supported it; and she opposed Obama’s push for the fast-track trade authority necessary to finalize the Trans-Pacific Partnership. Yet a September CNN poll found that Democrats were only 11 points more likely to view Pelosi favorably than unfavorably.

Gender scholars would not be surprised. For a 2010 paper in the Personality and Social Psychology Bulletin, the Yale researchers Victoria Brescoll and Tyler Okimoto showed study participants the fictional biographies of two state senators, identical except that one was named John Burr and the other Ann Burr. (I referred to this study in an October 2016 article for this magazine called “Fear of a Female President.”) When quotations were added that described the state senators as “ambitious” and possessing “a strong will to power,” John Burr became more popular. But the changes provoked “moral outrage” toward Ann Burr, whom both men and women became less willing to support.

Nancy Pelosi, by leading her party in Congress, has become Ann Burr. A woman can serve in Congress without being perceived as overly ambitious. By climbing to the top of the greasy pole, however, Pelosi has made her ambition visible. She has gained the power to tell her male colleagues what to do. (The pollster Celinda Lake notes that most ads attacking Pelosi show her speaking, not listening.) She has put herself, to quote the anti-Ossoff ad, “in control.”

For John Burr, this wouldn’t be a problem. As the management professors Ekaterina Netchaeva, Maryam Kouchaki, and Leah Sheppard noted in a 2015 paper, Americans generally believe “that leaders must necessarily possess attributes such as competitiveness, self-confidence, objectiveness, aggressiveness, and ambitiousness.” But “these leader attributes, though welcomed in a male, are inconsistent with prescriptive female stereotypes of warmth and communality.” In fact, “the mere indication that a female leader is successful in her position leads to increased ratings of her selfishness, deceitfulness, and coldness.”

The more successful Pelosi is—the more she outmaneuvers and dominates her male adversaries—the more threatening she becomes. And the easier it becomes to tar the male Democratic candidates who would serve under her as emasculated yes-men. Which makes it harder for Democrats to retake the House.

It would be comforting to think that Pelosi is alienating because she’s a rich liberal Democrat from San Francisco—not because she’s a woman. Yet despite attributes that should make her endearing to cultural conservatives—she is a Catholic Italian American grandmother of nine who entered politics only after staying home to raise her kids—many Americans greeted her rise with, in the words of the Yale researchers, “contempt, anger, and/or disgust.” It was the same for Hillary Clinton: Her deep religiosity, career-long focus on child welfare, and insistence on keeping her family together in the face of near-unimaginable humiliation didn’t spare her in the 2016 presidential election.

Similarly, if Senator Elizabeth Warren seeks the presidency, she won’t be able to count on help from her working-class Oklahoma roots and anti–Wall Street passion. On the surface, Trump’s “Pocahontas” slur may appear as unrelated to gender as Clinton’s emails did. But the moral outrage that female ambition provokes takes many forms. Already, notes Jennifer Lawless, who directs the Women and Politics Institute at American University, Republicans target Warren far more often than they target her populist doppelgänger, Senator Bernie Sanders. Not coincidentally, according to HuffPost, Americans approve of Sanders by a margin of 24 points—and of Warren by only four points.

A woman will one day make it to the White House. Nancy Pelosi may again become the speaker. But her experience offers an irony and a warning: For women politicians to succeed, they must defeat and outmaneuver men. Yet the better at it they are, the more detested they become.