The House passed the measure 228-206 late Friday, prompting prolonged cheers from the relieved Democratic side of the chamber. Thirteen Republicans, mostly moderates, supported the legislation while six of Democrats' farthest left members - including Reps. Alexandria Ocasio-Cortez of New York and Cori Bush of Missouri - opposed it.
Approval of the bill, which would create legions of jobs and improve broadband, water supplies and other public works, whisked it to the desk of a president whose approval ratings have dropped and whose nervous party got a cold shoulder from voters in this week's off-year elections.
WATCH: Pres. Biden speaks after infrastructure bill passes House
Democratic gubernatorial candidates were defeated in Virginia and squeaked through in New Jersey, two blue-leaning states. Those setbacks made party leaders - and moderates and progressives alike - impatient to produce impactful legislation and demonstrate they know how to govern. Democrats can ill afford to seem in disarray a year before midterm elections that could result in Republicans regaining congressional control.
Simply freeing up the infrastructure measure for final congressional approval was a like a burst of adrenaline for Democrats. Yet despite the win, Democrats endured a setback when they postponed a vote on a second, even larger bill until later this month.
That 10-year, $1.85 trillion measure bolstering health, family and climate change programs was sidetracked after moderates demanded a cost estimate on the sprawling measure from the nonpartisan Congressional Budget Office. The postponement dashed hopes that the day would produce a double-barreled win for Biden with passage of both bills.
NEW: Biden advances sweeping vaccine, COVID test mandates for private sector
But in an evening breakthrough brokered by Biden and House leaders, five moderates later agreed to back that bill if CBO's estimates are consistent with preliminary numbers that White House and congressional tax analysts have provided. The agreement, in which lawmakers promised to vote on the social and environment bill by the week of Nov. 15, stood as a significant step toward a House vote that could ultimately ship it to the Senate.
"Generations from now, people will look back and know this is when America won the economic competition for the 21st Century," Biden said in a written statement early Saturday.
The president and first lady Jill Biden delayed plans to travel Friday evening to their house in Rehoboth Beach, Delaware. Instead, Biden spoke to House leaders, moderates and progressives, said a White House official who described the conversations on condition of anonymity.
Rep. Pramila Jayapal, D-Wash., leader of the Congressional Progressive Caucus, said Biden even called her mother in India, though it was unclear why.
"This was not to bribe me, this is when it was all done," Jayapal told reporters. The lawmaker said her mother told her she "just kept screaming like a little girl."
In a two-sentence statement, the five moderates said that if the fiscal estimates on the social and environment bill raise problems, "we remain committed to working to resolve any discrepancies" to pass it. The five included Rep. Josh Gottheimer, D-N.J., leader of a group of centrists who this summer repeatedly pressured House Speaker Nancy Pelosi, D-Calif., to schedule earlier votes on the infrastructure bill.
In exchange, progressives agreed to back the infrastructure measure, which they'd spent months holding hostage in an effort to pressure moderates to back the larger bill.
MORE: Free community college proposal dropped from Biden's spending plan
The day marked a rare detente between Democrats' moderate and progressive wings that party leaders hope will continue this fall. The rival factions have spent recent weeks accusing each other of jeopardizing Biden's and the party's success by overplaying their hands and expressed a deep distrust of each other.
But Friday night, Jayapal suggested they would work together moving forward.
"Let me tell you, we're going to trust each other because the Democratic Party is together on this. We are united that it is important for us to get both bills done," she said.
The agreement came together after the White House issued a statement from Biden explicitly urging Democrats to support both bills. "I am confident that during the week of November 15, the House will pass the Build Back Better Act," he said.
When party leaders announced early in the day that the social and environment measure would be delayed, the scrambled plans cast a fresh pall over the party.
Democrats have struggled for months to take advantage of their control of the White House and Congress by advancing their top priorities. That's been hard, in part because of Democrats' slender majorities, with bitter internal divisions forcing House leaders to miss several self-imposed deadlines for votes.
"Welcome to my world," Pelosi told reporters, adding, "We are not a lockstep party."
Progressives had long demanded that the two massive bills be voted on together to pressure moderates to support the larger, more expansive social measure.
Democrats' day turned tumultuous early after a half-dozen moderates demanded the CBO cost estimate of the sprawling package of health, education, family and climate change initiatives before they would vote for it.
Party leaders said that would take days or more. But with Friday's delayed vote and lawmakers leaving town for a week's break, those budget estimates should be ready by the time a vote is held.
The infrastructure measure cleared the Senate in August with bipartisan support. The package would provide huge sums for highway, mass transit, broadband, airport, drinking and waste water, power grids and other projects.
But it became a pawn in the long struggle for power between progressives and moderates. Early Friday, Jayapal said the White House and Congress' nonpartisan Joint Committee on Taxation had provided all the fiscal information lawmakers needed for the broad bill. She suggested that progressives would oppose the infrastructure bill unless the two measures were voted on together.
But that changed after the two Democratic factions reached their agreement.
House passage of the social and environment package would send it to the Senate, where it faces certain changes and more Democratic drama. That's chiefly because of demands by Sens. Joe Manchin of West Virginia and Kyrsten Sinema of Arizona to contain the measure's costs and curb or drop some of its initiatives.
Moderates have forced leaders to slash the roughly 2,100-page measure to around half its original $3.5 trillion size. Republicans oppose it as too expensive and damaging to the economy.
The package would provide large numbers of Americans with assistance to pay for health care, raising children and caring for elderly people at home. The package would provide $555 billion in tax breaks encouraging cleaner energy and electric vehicles. Democrats added provisions in recent days restoring a new paid family leave program and work permits for millions of immigrants.
Much of the package's cost would be covered with higher taxes on wealthier Americans and large corporations.
Associated Press writers Lisa Mascaro, Farnoush Amiri, Kevin Freking, Aamer Madhani, Alexandra Jaffe, Mary Clare Jalonick and Brian Slodysko contributed to this report.