Nancy Pelosi knew this moment would come, even if others had their doubts — or worked to stop her.

Pelosi is poised to be elected Thursday as House speaker, the only woman who has held the office and now one of few elected officials who will be returning to it. The last time a speaker regained the gavel was more than a half-century ago.

The California Democrat has spent her political career being underestimated, only to prove the naysayers wrong. In this case, it was by winning back the Democratic majority and amassing the votes for the speaker’s job.

“None of us is indispensable,” Pelosi told The Associated Press on the campaign trail last fall, “but I do know that I’m very good at what I do.”

In accepting the gavel, Pelosi will give a nod to the new era of divided government with a pledge to “reach across the aisle in this chamber and across the divisions in this great nation,” according to excerpts of her prepared remarks Thursday.

“The floor of this House must be America’s Town Hall: where the people will see our debates and where their voices will be heard and affect our decisions,” she says.

In previewing Democratic priorities, she talks about lowering health care costs, investing in green infrastructure and “restoring integrity” to government.

“We must be champions of the middle class and all those who aspire to it — because the middle class is the backbone of democracy,” she says.

Pelosi remains a highly polarizing figure, vilified by Republicans as a San Francisco liberal and a caricature of big government. But she is also a mother of five and a grandmother of nine who has shattered glass ceilings to become one of the most powerful politicians of the 21st century.

With President Donald Trump in the White House and Republicans still controlling the Senate, Pelosi’s return to the speaker’s office to lead a Democratic majority with its biggest freshmen class since Watergate shakes up the dynamic in Washington even beyond the new era of divided government.

Pelosi has faced pressure from some incoming Democrats who have been willing to talk about the possibility of impeachment proceedings against Trump. Pelosi has called impeachment a “divisive activity,” and Democrats were cautious about mentioning the “I” word during the 2018 midterms for fear it would backfire politically.

But Pelosi did not shy away from it Thursday in an interview airing on NBC’s “Today” show.

“We shouldn’t be impeaching for a political reason, and we shouldn’t avoid impeachment for a political reason,” she said, adding that she would wait for the findings of special counsel Robert Mueller’s investigation into Russia meddling in the 2016 election.

Only the House can begin impeachment proceedings. And while Justice Department guidelines suggest a sitting president can’t be indicted, Pelosi called that “an open discussion.”

“Everything indicates that a president can be indicted after he is no longer president,” she said.

Trump himself has denied any wrongdoing.

Pelosi is one of the few congressional leaders who seem to understand Trump, both being children from famous families now primed for deal-making. Trump appreciates strong characters, and, in perhaps a sign of respect, she is one of the few congressional leaders in Washington he has not given a nickname — though he has made her a frequent target.

Pelosi’s return to the speaker’s office was not guaranteed. A core group of rank-and-file Democrats has hungered for new leadership, saying it’s time for a new generation to take the helm. They tired of the Republican attack ads featuring Pelosi that are constantly run against them back home, and they worried she would be a drag on efforts to keep the majority in the next election. They enlisted some of the newcomers from the freshmen class to their ranks to try to stop her from regaining the gavel.

But one by one, Pelosi peeled away the skeptics, flipping “no” votes to the “yes” column, sometimes in a matter of days. Some were given lead positions on their legislative priorities, even a gavel of their own to chair special panels.

And Pelosi gave a little, too, promising, at 78, to serve no more than four years in leadership, making way for the next generation.

It’s unclear what the final tally will be when votes for speaker are counted Thursday as the first act of the new Democratic majority.

“She’ll be more than fine,” said Rep. Hakeem Jeffries of New York, the incoming chairman of the Democratic caucus.

Jeffries said when he told his family that, because of his new position, he may be the one to put Pelosi’s name forward during the nomination proceeding, his youngest son said to him, “Don’t blow the moment, Dad.”

AP Photo/J. Scott Applewhite