Andrew Harnik / AP

Updated on November 30 at 1:05 p.m. ET

Nancy Pelosi will be the most powerful woman in Congress for another two years.

The veteran Democrat on Wednesday beat back a surprisingly strong challenge from Representative Tim Ryan of Ohio to win reelection as leader of the minority party in the U.S. House. In a secret ballot, Pelosi won 134 votes to Ryan’s 63—or just over two-thirds of the Democratic caucus.

The leadership race was the most difficult for Pelosi in the nearly 10 years since she became the first woman speaker of the House and the highest-ranking elected woman in the U.S. government. She lost significantly more votes on Wednesday than she did when she faced a challenge from Representative Heath Shuler of North Carolina in 2010 after Democrats lost the House majority. Shuler only won 43 votes.

Now 76, the California liberal has for years retained broad support within a Democratic caucus in the House that she ran with exacting control. But in the wake of Donald Trump’s surprising victory in the presidential election and a weaker-than-expected showing by House Democratic candidates, she faced opposition from dozens of lawmakers who believed the party needed a change at the top and a leader who could better connect with the white working-class voters who backed Trump. Republicans have now won the House majority in three straight elections, and Trump’s victory has prompted Democrats throughout the party to question whether their focus on cultural issues has kept them from winning races beyond their urban base of blacks, Hispanics, and liberal whites.

A Republican target for years, Pelosi had become the face of that debate in recent weeks, and Ryan, a 43 year old who represents the old steel city of Youngstown, Ohio, stood up to challenge her. He attracted support from junior members of the caucus who were frustrated that the continuing reign of Pelosi and her two septuagenarian lieutenants, Representatives Steny Hoyer of Maryland and James Clybur South Carolina, had stifled their advancement on key committees and the leadership. But Ryan was an imperfect candidate from the start: He had few concrete accomplishments to show for his 14 years serving in the House and a nonexistent base of support from which to unseat Pelosi.

“We knew it was an uphill battle,” Ryan told reporters after the vote. “Leader Pelosi has been here a long time. She has a lot of friends. This is her caucus, clearly.”

Yet Ryan and his allies took heart in the scare they put in Pelosi, who projected confidence throughout the two-week campaign in public but scrambled behind the scenes to make changes that would secure her victory. She announced a series of moves aimed at allowing younger lawmakers to rise faster in committees and have a voice in the party leadership. And the night before the vote, 85-year-old Representative Sander Levin of Michigan revealed that he would not seek another term as the top Democrat on the House Ways and Means Committee, the panel charged with writing tax policy and overseeing Medicare, Medicaid, and Social Security. Pelosi’s hand was seen in that decision, which cleared the way for younger Democrats to take over.

Pelosi also made clear that Democrats would focus on core economic issues in the new Congress, including pushing for an expansive infrastructure jobs package and fighting Republican attempts to dismantle Medicare. “We now have a leadership that is listening to what we say,” said Representative Marcia Fudge of Ohio, a former chairwoman of the Congressional Black Caucus who supported Ryan. “He didn’t lose today. Today, we made a caucus more responsive to its members.”

In a short statement to reporters Wednesday, Pelosi said she was “exhilarated” by the victory and only briefly mentioned Ryan by way of congratulating him for running a good race. Saying she was heartbroken that Hillary Clinton lost the presidency, Pelosi vowed to confront Trump in what she called “a historic challenge.”

“We know how to win elections. We’ve done it in the past, and we will do it again,” she said. “This is about so much bigger than politics. It’s about the character of America.”

As she headed back into the party meeting, the woman renowned for her vote-counting skills reminded reporters that she had once again met her mark. She had claimed the support of more than two-thirds of the caucus all month. In the end, she won 68 percent of the vote.

We want to hear what you think about this article. Submit a letter to the editor or write to letters@theatlantic.com.