WASHINGTON (AP) -- Up against one last deadline, Congress raced to pass legislation Wednesday avoiding a threatened national default and ending a 16-day partial government shutdown along the strict terms set by President Barack Obama when the twin crises began.
"We fought the good fight. We just didn't win," conceded House Speaker John Boehner as lawmakers lined up to vote on a bill that includes nothing for Republicans demanding to eradicate or scale back Obama's signature health care overhaul.
The stock market surged higher at the prospect of an end to the crisis that also had threatened to shake confidence in the U.S. economy overseas.
A Senate vote was set first on the legislation, which would permit the Treasury to borrow normally through Feb. 7 or perhaps a month longer, and fund the government through Jan. 15. More than two million federal workers — those who had remained on the job and those who had been furloughed — would be paid under the agreement.
Across the Capitol, members of the House marked time until their turn came to vote.
Only a temporary truce, the measure set a timeframe of early next winter for the next likely clash between Obama and the Republicans over spending and borrowing.
But for now, government was lurching back to life. In one example, officials met to discuss plans for gearing back up at the Department of Housing and Urban Development, where 307 employees remained at work during the partial shutdown and more than 8,000 were furloughed.
After weeks of gridlock, the measure had support from the White House, most if not all Democrats in Congress and many Republicans fearful of the economic impact of a default.
Boehner and the rest of the top GOP leadership told their rank and file they would vote for the measure, and there was little or no doubt it would pass both houses and reach the White House in time for Obama's signature before the administration's 11:59 p.m. Oct. 17 deadline.
That was when Treasury Secretary Jacob Lew said the government would reach the current $16.7 trillion debt limit and could no longer borrow to meet its obligations.
Tea party-aligned lawmakers who triggered the shutdown that began on Oct. 1 said they would vote against the legislation. Significantly, though, Texas Sen. Ted Cruz and others agreed not to use the Senate's cumbersome 18th century rules to slow the bill's progress.
"The compromise we reached will provide our economy with the stability it desperately needs," said Senate Majority Leader Harry Reid, declaring that the nation "came to the brink of disaster" before sealing an agreement.
Senate Republican Leader Mitch McConnell, who negotiated the deal with Reid, emphasized that it preserved a round of spending cuts negotiated two years ago with Obama and Democrats. As a result, he said, "government spending has declined for two years in a row" for the first time since the Korean War. "And we're not going back on this agreement," he added.
McConnell made no mention of the polls showing that the shutdown and flirtation with default have sent Republicans' public approval plummeting and have left the party badly split nationally as well as in his home state of Kentucky. He received a prompt reminder, though.
"When the stakes are highest Mitch McConnell can always be counted on to sell out conservatives," said Matt Bevin, who is challenging the party leader from the right in a 2014 election primary.
More broadly, national tea party groups and their allies underscored the internal divide. The Club for Growth urged lawmakers to vote against the congressional measure, and said it would factor in the organization's decision when it decides which candidates to support in midterm elections next year.
"There are no significant changes to Obamacare, nothing on the other major entitlements that are racked with trillions in unfunded liabilities, and no meaningful spending cuts either. If this bill passes, Congress will kick the can down the road, yet again," the group said.
Even so, support for Boehner appeared solid inside his fractious rank and file. "There are no plots, plans or rumblings that I know of. And I was part of one in January, so I'd probably be on the whip list for that," said Rep. Thomas Massie of Kentucky.
The U.S. Chamber of Commerce came out in favor of the bill.
Simplicity at the end, there was next to nothing in the agreement beyond authorization for the Treasury to resume borrowing and funding for the government to reopen.
House and Senate negotiators are to meet this fall to see if progress is possible on a broad deficit-reduction compromise of the type that has proved elusive in the current era of divided government.
Additionally, Health and Human Services Secretary Kathleen Sebelius is to be required to produce a report stating that her agency is capable of verifying the incomes of individuals who apply for federal subsidies under the health care law known as Obamacare.
Obama had insisted repeatedly he would not pay "ransom" by yielding to Republican demands for significant changes to the health care overhaul in exchange for funding the government and permitting Treasury the borrowing latitude to pay the nation's bills.
Other issues fell by the wayside in a final deal, including a Republican proposal for the suspension of a medical device tax in Obamacare and a Democratic call to delay a fee on companies for everyone who receives health coverage under an employer-sponsored plan.
The gradual withering of Republicans' Obamacare-related demands defined the arc of the struggle that has occupied virtually all of Congress' time for the past three weeks.
The shutdown began on Oct. 1 after Cruz and his tea party allies in the House demanded the defunding of the health care law as a trade for providing essential government funding.
Obama and Reid refused, then refused again and again as Boehner gradually scaled back Republican demands.
The shutdown initially idled about 800,000 workers, but that soon fell to about 350,000 after Congress agreed to let furloughed Pentagon employees return to work. While there was widespread inconvenience, the mail was delivered, Medicare continued to pay doctors who treated seniors and there was no interruption in Social Security benefits.
Still, national parks were closed to the detriment of tourists and local businesses, government research scientists were sent home and Food and Drug Administration inspectors worked only sporadically.
Obama and Boehner both came to the same conclusion — that they would allow the shutdown to persist for two weeks, until it became politically possible to reopen government and address the threat of default at the same time.
As Republican polls sank, Boehner refused to let the House vote on legislation to reopen the entire government, insisting on a piecemeal approach that the White House and Reid rejected as insufficient.
As the Oct. 17 debt-limit deadline approached, there were warnings from European officials as well as Cabinet members and bankers in this country that failure to raise the debt limit invited an economic disaster far worse than the near-meltdown of 2008.
On Tuesday, the Fitch credit rating agency said it was reviewing its AAA rating on U.S. government debt for possible downgrade.
By then, the endgame was underway.
Late last week, Obama met with Boehner and House Republicans at the White House. The session resulted in brief follow-up talks in which GOP aides suggested easing the across-the-board spending cuts in exchange for changes in benefit programs such as making Medicare more expensive for better-off beneficiaries.
After that faltered, Reid and McConnell announced over the weekend they were seeking a deal to solve the crises, and expressed hope they could quickly come to an agreement.
That effort was suspended on Tuesday, a day of suspense in which Boehner made one last stab at a conservatives' solution. When his rank and file refused to coalesce around any proposal, he gave up and McConnell and Reid returned to their labors.
Associated Press writers Donna Cassata, Alan Fram, Andrew Taylor, Henry C. Jackson, Bradley Klapper, Laurie Kellman, Julie Pace and Jim Kuhnhenn contributed to this story.