In December 2018, weeks after the Democrats’ conquest of the House, the soon-to-be speaker arrived for a White House meeting with Donald Trump. The subject was a government shutdown but the subtext was a showdown between the most powerful woman in American politics and the president of the United States.

In the extraordinary, televised exchange that followed, Trump sought to undermine Nancy Pelosi, whom he repeatedly addressed as “Nancy”, by reminding his audience in the Oval Office – and those watching at home – that she had yet to secure the 218 votes needed to reclaim the speakership and was “in a situation where it’s not easy for her to talk right now”.

Her response was sharp and sure. “Mr President, please don’t characterize the strength that I bring to this meeting.”

It was the first test of a new power dynamic in Washington and when it ended, there was little disagreement over who had won.

Pelosi emerged from the White House wearing a now-famous burnt-orange coat, sunglasses and the triumphant smile of a woman who has never forgotten the advice imparted to her by the late Louisiana congresswoman Lindy Boggs: “Darlin’, know thy power and use it.”

Nancy Pelosi gets under the president’s skin in a meeting in the White House cabinet room on 17 October. Photograph: White House/Reuters

That 15-minute Oval Office meeting marked the beginning of a struggle between Pelosi and Trump that culminated last week in the president’s impeachment by the House of Representatives for “high crimes and misdemeanors”. Pelosi, dressed in funeral black, banged down her speaker’s gavel to finalize the vote, binding together their legacies for all time.

It was not how Pelosi, who once said Trump was “not worth” impeaching, had hoped to end a year that began with her historic, second ascension to the speakership. Pelosi, the first – and only – woman ever to serve as Speaker of the House, would rather be remembered for legislative accomplishments – the Affordable Care Act above all – than for impeachment. But Trump, Pelosi said, left her “no choice”. She quoted Thomas Paine: “The times have found us.”

In the wake of Trump’s impeachment, however, Democrats believe there was perhaps no leader better suited to the times.

“She is, thank God, the exact right person in the right place at the right time,” said Leon Panetta, a former defense secretary and CIA director and a California native who’s known Pelosi for decades. “I’m not sure anybody else would have had the experience or capability to be able to do what she has done.”

“Donald Trump really has met his match with Nancy,” Panetta added.

Her grace under fire as speaker has earned comparisons to Sam Rayburn, the country’s longest-serving speaker, who died in 1961. One Democrat called her an “as good or better” legislative leader than Lyndon Johnson, who was a Senate majority leader before he was president.

And when the question is asked whether a female presidential candidate can beat Trump in 2020, the Democrats point to Pelosi, who “does it every single day”.

Even Senator Lindsey Graham, one ofTrump’s fiercest defenders these days, is impressed. In an interview with CNN decrying the impeachment process, the South Carolina senator called it “quite a feat” that she was able to advance bipartisan legislation even as efforts to remove Trump cleaved the House – and the nation.

***

The women of the 116th Congress, including House Speaker Nancy Pelosi, center front row, pose for a group photo on Capitol Hill in Washington. Photograph: Susan Walsh/AP

In the last year, Pelosi has guided her factious congressional caucus through the choppy waters of Trump’s presidency. Like a political grandmaster of three-dimensional chess she quelled an insurrection to reclaim the gavel, engineered the end of the longest government shutdown in US history, and impeached the president, all while averting another shutdown and negotiating with the White House on a trade deal with Canada and Mexico.

“We got a lot done this year in spite of impeachment,” said congressman Tim Ryan, an Ohio Democrat, who unsuccessfully challenged Pelosi for Democratic leader in 2016. He said it was a testament to the “skillful way” Pelosi has led the House.

Pelosi learned her tactics from her father, Thomas D’Alesandro, a Democratic mayor of Baltimore and former congressman. From her family home in Baltimore’s Little Italy she learned the skills that make Pelosi, by her own account, a “master legislator:” how to count votes, dole out favors and strike “back-room” deals.

But her leadership training came later, as the stay-at-home mother of five children.

“If the five of us couldn’t rattle her, Donald Trump isn’t going to,” said Christine Pelosi, Pelosi’s daughter and the author of The Nancy Pelosi Way: Advice on Success, Leadership, and Politics from America’s Most Powerful Woman.

The Democratic 2020 candidates could learn from watching her mother stand up to Trump, she said, because “the next president of the United States has to be at least as good and certainly as solid as Nancy Pelosi”.

Pelosi brought her life’s lessons to bear during her legislative career, particularly during the early years of the Obama administration when she helped usher the Affordable Care Act, a landmark healthcare law, climate change legislation and a massive economic stimulus package to mitigate the fallout from the financial crisis. It’s also how she returned to speaker in 2019.

Nancy Pelosi gestures to a stack of bills the Democratic-controlled House of Representatives under her leadership has sent to the Senate in 2019. Photograph: Jim Lo Scalzo/EPA

“Her second time as speaker is the culmination of all of her strengths – mastering the legislative process, counting votes, uniting a caucus with many factions, looking two steps ahead,” said Stacy Kerr, a former senior adviser to Pelosi.

But her return to power was not guaranteed after the 2018 midterms swept a historic class of women and people of color to power. Opposition came mostly from incoming freshman Democrats in conservative districts who had made campaign vows not to support her for speaker. The fight to displace Pelosi was largely centered on appeals for new leadership and generational change – but no candidate ever emerged to challenge her. Pelosi won handily – and now presides over the most diverse and most female Democratic majority in history.

“Those folks who thought that Nancy wasn’t up to the job way back when, they are all silent now,” said congressman Gregory Meeks, a Democrat from New York. “She has been the absolute master conductor.”

***

Nationally, Pelosi is an unpopular and polarizing figure. Republicans have spent years – and many millions of dollars – turning her into a villain on the right and a political liability on the left, particularly among moderate Democrats in swing districts.

But Pelosi has reemerged in the Trump era as a political and cultural icon of the left.

An image of Pelosi, lips pursed in an arch smile, eyes locked on Trump, applauding during the 2019 State of the Union address ripped across social media as the ultimate “clapback”.

In October, Trump tweeted a photo that was supposed to show Pelosi’s “unhinged meltdown” during a White House meeting – the speaker at a table of mostly men, literally standing up to Trump. But her supporters saw instead a symbol of female power and Pelosi made the picture the background photo on her Twitter page.

This image of Pelosi, lips pursed in an arch smiled, eyes locked on Trump, applauding during the 2019 State of the Union address ripped across social media as the ultimate “clapback”. Photograph: Doug Mills/The New York Times/Pool via Getty

There was another revealing moment this month, when a reporter for the conservative Sinclair Broadcast Group, asked: “Do you hate the president, Madam Speaker?” She turned to face him directly, her voice quivering but forceful. “I don’t hate anyone,” she said sharply, adding: “Don’t mess with me when it comes to words like that.”

These snapshots of Pelosi’s power have drawn admirers from unexpected quarters. Lara Trump, who is married to Trump’s son, Eric, recently praised Pelosi’s “tenacity” and remarked on her ability to “put down and throw down whenever she needs to”.

Her steeliness has enraged Trump, who has a long history of lashing out at powerful women. But his taunts became increasingly vindictive and personal in the months leading up to his impeachment. In October he assailed her “unhinged meltdown” and pressed the ill-suited nickname, “Nervous Nancy”. This month he claimed bizarrely that Pelosi’s teeth were “falling out”. And in a six-page letter to Pelosi he accused her of lying when she says she prays for him, unless her prayers are meant “in the negative sense”.

“It is a terrible thing you are doing, but you will have to live with it, not I!” he wrote.

The Louisiana congressman Steve Scalise, the House minority whip, said impeachment “will be a stain on Nancy Pelosi’s legacy as speaker” that overshadows her legislative record.

“It’s clear this is only about carrying out a personal vendetta against the president and that’s not why you use the power of impeachment,” he said. “That’s an abuse of power.”

***

Speaker of the House Nancy Pelosi arrives at the U.S. Capitol and walks to her office on December 18, 2019 in Washington, DC. Photograph: Drew Angerer/Getty Images

Pelosi’s role in the third presidential impeachment trial is not quite finished. She must send the articles of impeachment to the Senate and appoint managers to present the House’s case in a trial next year – though she has suggested she may delay doing so.

A top priority next year will be protecting her House majority, especially vulnerable members who may have risked their re-election on supporting impeachment.

“We fully intend to win,” she said recently, of the November elections.