WASHINGTON — To hear Rep. Nancy Pelosi tell it, her quiet but firm push to get President Joe Biden to withdraw from the 2024 race was a simple matter of the ruthless political math that she has spent decades honing a talent for on Capitol Hill.

“My goal is defeat Donald Trump,” Pelosi, the former speaker, said in a recent interview before the release this week of a book on her years in Congress. “And when you make a decision to defeat somebody, you make every decision in favor of that. You don’t mess around with it, OK? What is in furtherance of reaching that goal? I thought we had to have a better campaign.”

The book, “The Art of Power,” is Pelosi’s retelling of major moments of critical decision-making during the Iraq War, a catastrophic financial meltdown, the passage of the Affordable Care Act and multiple clashes with former President Trump, among other events.

But it may be her most recent deft exercise of political finesse and muscle — one that took place well after the book was written — that will stand as a final testament to Pelosi’s stature as the Democratic Party’s premiere powerhouse of recent decades. In a formidable display of her enduring clout, she helped persuade the incumbent president to abandon his reelection bid to give her party a better chance of holding the White House in November.

Pelosi plays down her role in nudging Biden aside and insists that the decision was his alone to make. In her focus on polls and fundraising and in private conversations with the president and rattled Democratic colleagues, she said, she was driven by the single imperative of beating Trump.

The former speaker said she did not initiate calls with colleagues, trying to dispel claims that she had orchestrated the ouster of Biden, a longtime ally. But if Democrats triumph this fall after staring down the prospect of a resounding defeat, the maneuvering by Pelosi — along with personal appeals to Biden from Democratic congressional leaders Sen. Chuck Schumer and Rep. Hakeem Jeffries, both of New York — may turn out to be among her most significant acts.

The words “Pelosi” and “power” have been inextricably linked in Washington for more than 20 years, and her book sets out to document how she did it.

She rose to the top at a time when men presumed to dominate in Congress and hold women beneath the “marble ceiling,” a term she uses in a nod to the common building block on Capitol Hill that is far more difficult to break than glass. She was prompted to run for the party’s No. 2 leadership post in 2001, after congressional losses to Republicans that began in 1994. She quickly ran into opposition from male colleagues.

“The men explained to me that the House had a pecking order, that other male representatives had been dutifully waiting in line for an upper-level leadership post to open, that I was cutting in and overturning the established order of things,” Pelosi wrote.

She won that race and became the top House Democrat a year later, a position she held until 2022. Like many successful congressional leaders, Pelosi had no ambition beyond the House, reveling in the legislative process. It came with a cost.

In a chapter titled “Leadership’s Price,” Pelosi recounts the horrific attack on her husband, Paul, by a hammer-wielding assailant in their San Francisco home in 2022, and her guilt over the assault. And she passes harsh judgment on Trump, with whom she fought from their first White House meeting, when she pushed back as he falsely asserted that he won the popular vote, through two impeachments.

One notable revelation in the book is a phone conversation initiated by Trump on the morning of Sept. 24, 2019, just as she was about to announce an impeachment inquiry against him. He started out with a pretense of discussing legislation, but Pelosi writes that the real reason behind the outreach was to try to deter her from investigating a phone call in which Trump tried to persuade Ukraine President Volodymyr Zelenskyy to investigate Biden, Trump’s rival, or risk losing congressionally approved aid.

“Again and again during the more than 20-minute call, Trump repeated, ‘It was a perfect call,’ ” she wrote. Pelosi said she ended the conversation by telling him the truth would emerge.

“I’ve had a lot of conversations with this man,” she wrote, “and at the end of nearly all of them, I think, ‘Either you are stupid, or you think that the rest of us are.’ ”

As speaker, Pelosi was known for her ability to produce just enough votes to carry the day on tough issues, applying her deep knowledge of individual members and their needs to accumulate 218 votes, the bare majority, and always holding a few more in her pocket just in case.