WASHINGTON (AP) — Senate leaders announced last-minute agreement Wednesday to avert a threatened Treasury default and reopen the government after a partial, 16-day shutdown. Congress raced to pass the measure by day's end.

The Dow Jones industrial average soared on the news that the threat of default was fading, flirting with a 200-point gain in morning trading.

"This is a time for reconciliation," said Senate Majority Leader Harry Reid of the agreement he had forged with the GOP leader, Sen. Mitch McConnell of Kentucky.

It was a jubilant moment in the chamber, which on Tuesday was forced to sit back and watch as the effort by House GOP leaders for a bill collapsed in disarray.

McConnell said that with the Senate accord, Republicans had sealed a deal to have spending in one area of the budget decline for two years in a row, adding, "we're not going back."

One prominent tea party lawmaker, Sen. Ted Cruz of Texas, said he would oppose the plan, but not seek to delay its passage.

That was a key concession that signaled a strong possibility that both houses could act by day's end. That, in turn, would allow President Barack Obama to sign the bill into law ahead of the Thursday deadline that Treasury Secretary Jacob Lew had set for action to raise the $16.7 trillion debt limit.

While the deal could meet resistance from conservatives in the Republican-controlled House, the Democratic Leader, Rep. Nancy Pelosi of California, supports the plan and says her rank and file is expected to vote for it in overwhelming numbers. That raised the possibility that more Democrats than Republicans would back it, potentially causing additional problems for House Speaker John Boehner as he struggles to manage his tea party-heavy majority.

After abandoning their own plan on Tuesday, House members quietly awaited Senate action, resigned to the likelihood that they would have to back the deal or plunge the nation into default. The only silver lining was the promise that it would be their last vote for the week after three straight weekends in Washington.

Story continues

Officials said the proposal called for the Treasury to have authority to continue borrowing through Feb. 7, and the government would reopen through Jan. 15.

The White House welcomed the compromise and spokesman Jay Carney said the president looked forward to signing it into law.

In political terms, the final agreement was almost entirely along lines Obama had set when the impasse began last month. Tea party conservatives had initially demanded the defunding of the health care law as the price for providing essential federal funding.

Under a strategy set by Obama and Reid, Democrats said they would not negotiate with Republicans in exchange for performing what the White House called basic functions of keeping the government in operation and preventing Treasury from defaulting on its obligations.

A long line of polls charted a steep decline in public approval for Republicans in the course of what Sen. John McCain, R-Ariz., pronounced a "shameful episode" in the nation's history.

Wednesday's developments came one day before the deadline Lew had set for Congress to raise the current $16.7 trillion debt limit. Without action by lawmakers, he said, Treasury could not be certain it had the ability to pay bills as they come due.

In addition to raising the debt limit, the proposal would give lawmakers a vote to disapprove the increase. Obama would have the right to veto their opposition, ensuring he would prevail.

House and Senate negotiators would be appointed to seek a deficit-reduction deal. At the last minute, Reid and McConnell jettisoned a plan to give federal agencies increased flexibility in coping with the effects of across-the-board cuts. Officials said that would be a topic for the negotiations expected to begin shortly.

The deal would provide back pay to the 800,000 federal workers affected by the shutdown, including half who have been idled for more than two weeks.

Despite initial Republican demands for the defunding of the health care law often derided as "Obamacare," the pending agreement makes only one modest change touching on the program. It relates to a requirement that individuals and families seeking subsidies to purchase coverage verify their incomes before qualifying.

The deal was reached after dire warnings from the financial world. The Fitch credit rating agency said it was reviewing its AAA rating on U.S. government debt for possible downgrade. John Chambers, chairman of Standard & Poor's Sovereign Debt Committee, told "CBS This Morning" that a U.S. government default on its debts would be "much worse than Lehman Brothers," the investment firm whose 2008 collapse led to the global financial crisis.

The Senate pact had been put on hold Tuesday, an extraordinary day that highlighted how unruly rank-and-file House Republicans can be, even when the stakes are high. Facing solid Democratic opposition, Boehner tried in vain to write legislation that would satisfy GOP lawmakers, especially conservatives.

Boehner crafted two versions of the bill, but neither made it to a House vote because both faced certain defeat. Working against him was word during the day from the influential Heritage Action for America group that his legislation was not conservative enough — a worrisome threat for many GOP lawmakers whose biggest electoral fears are of primary challenges from the right.

Boehner's inability to produce a bill that could pass his own chamber likely means he will have to let the House vote on a Senate compromise, even if that means it would pass with strong Democratic and weak GOP support. House Republican leaders have tried to avoid that scenario for fear that it would threaten their leadership, and some Republicans worried openly about that.

___

Associated Press writers David Espo, Andrew Taylor, Charles Babington, Stephen Ohlemacher, Henry C. Jackson and Donna Cassata contributed to this report.