WASHINGTON — Deep into the grueling negotiations over President Biden’s big domestic policy package, when it seemed that bickering among Democrats would never stop, House Speaker Nancy Pelosi let everyone in on a little secret.

“This,” she told reporters, “is the fun part.”

The grind of legislating — treacherous for some, a sport for others, and often unsuccessful in the slow-moving Congress — is where Pelosi resides, exerting relentless drive to advance Biden’s $1.7-trillion package through the House on Friday, sending it to the Senate.

The House vote, with just one Democrat opposed, boosts momentum for Biden’s signature legislation after months of start-and-stop negotiations, and provides a down payment on the party’s campaign promise to deliver competency in government and put it to work for Americans.

And for Pelosi, who breezed into the House chamber early Friday to gavel the vote closed after a nearly all-night session, the outcome is a career milestone that further cements the first female speaker’s legacy as one of the nation’s most powerful House leaders — one who is working to secure massive federal investments that Biden and others have likened to Franklin D. Roosevelt’s New Deal or Lyndon B. Johnson’s Great Society.

“Congratulations,” Biden told Pelosi in a phone call as the final tally rolled in.

Friday’s vote was never a sure thing. The final action in some ways sneaked up on lawmakers after frenzied weeks of negotiations, several false starts and high-profile setbacks that delayed and threatened to derail the entire enterprise.

First, there was the difficult process of compiling the 2,135-page “Build Back Better Act,” with its far-reaching proposals to help families afford healthcare and child care and lower the price of prescription drugs, alongside new efforts to tackle climate change.

Then, facing a solid wall of Republican opposition, the Democrats had to decide whether they could approve the bill on their own, which required multiple rounds of private meetings and public hand-wringing between centrist and progressive factions.

Any misstep along the way could sideline a congressional leader, especially one without the political fortitude to push and pull lawmakers to fall in line. Pelosi’s immediate predecessors, Paul D. Ryan and John A. Boehner, both retired and gave up the gavel after struggling to lead Republicans.

But Pelosi, who has represented San Francisco in Congress for more than 30 years, not only has the stomach for such gut-wrenching talks, she has turned the perils of legislating into political opportunities, showcasing the party’s factions. “Diversity is our strength” is among her maxims.

When she has heard and seen enough, she digs in and pushes ahead, relying on the other Pelosi maxim — “Unity is our power” — to reach resolution.

Meeting privately with House leaders Monday evening, she signaled that it was time to move.

Pelosi told them there had been “a little too much drama,” according a Democratic aide familiar with the private meeting, who was granted anonymity to discuss it.

The House had already approved the related $1-trillion infrastructure package, a roads-bridges-and-broadband measure favored by centrist lawmakers after poor election showings in Virginia and New Jersey served as a wake-up call to Democrats. Now, according to Pelosi’s strategy, it was time to make good on the commitment for Biden’s broader vision, a major goal of progressives.

“It was a long road because ... the sheer amount of impact we’re trying to have is enormous,” Rep. Andy Kim (D-N.J.) said Friday.

“It’s always complicated; I mean, when you’ve got people representing every corner of this country, there’s always going to be complexity, but that’s the art of governing,” he added.

Pelosi has been here before. A decade ago, she led House Democrats to passage of the Affordable Care Act, a yearlong effort that consumed Congress at the start of President Obama’s first term and contributed to the party’s electoral wipeout in the 2010 midterm election.

Pelosi lost the speaker’s gavel after Republicans regained control of the House in 2011, and today’s Republicans are expecting a repeat in 2022 as they heap criticisms on Biden’s bill as big government overreach.

Minority Leader Kevin McCarthy (R-Bakersfield), who is in line to become speaker if Democrats lose control of the House next year, set the tone in an overnight speech full of vitriol and grievance against Biden, the Democrats and Pelosi in particular, as he chided her leadership and wished for her retirement.

If he sounded “angry,” McCarthy said, it’s because he was. His eight-hour-plus speech set a new House record, besting one set just a few years back by Pelosi. But his protest did not stop the vote.

Pelosi responded with one of the most politically biting strategies in her arsenal — she ignored him.

Early Friday morning, she delivered a sunny speech in stark contrast to McCarthy’s dark mood.

“Under this dome, for centuries, members of Congress have stood exactly where we stand to pass legislation of extraordinary consequence in our nation’s history and for our nation’s future,” Pelosi said.

The setting is a reminder, she said, “that our words and actions will face the judgment of history, and that we are part of the long and honorable heritage of our democracy.”

Democrats cheered the measure’s passage on the House floor, chanting, “Nancy, Nancy!” Sullen Republicans at one point belted out, “Hey, hey, goodbye,” some waving across the aisle.

One newcomer to Congress, Rep. Carolyn Bourdeaux (D-Ga.), said the bill’s programs for free prekindergarten for all 3- and 4-year-olds, alongside affordable healthcare options, are priorities that policymakers have been trying to achieve for decades.

“We’re addressing needs that have been around for a long, long time,” she said after the vote. “People need to realize every other developed country in the world has a lot of these benefits, and it’s time for us to have that, too.”

She added, “We have really accomplished something amazing.”

Mascaro writes for the Associated Press. AP writer Farnoush Amiri contributed to this report.