Democratic and Republican leaders traded blame on Friday in a budget impasse that threatened to shut down the government within hours and idle hundreds of thousands of federal workers.

With a midnight deadline looming, President Barack Obama's aides and lawmakers struggled for a deal over government funding for the rest of the fiscal year, which ends September 30. But the two sides could not even agree on what issues were holding up an agreement.

Democrats said they were at odds over federal funding for birth control. Republicans said spending cuts were the issue.

Without an agreement, money to operate the federal government for the next six months would run out at midnight on Friday and agencies such as the Internal Revenue Service would begin a partial shutdown.

Congressional staffers were making some progress in last-minute talks, a Republican aide said. But it was unclear whether a deal, even for a few extra days of stopgap funding, could be struck in time. Obama scrapped a family weekend trip to Williamsburg, Virginia, to stay home and monitor events.

The bitter political fight raised questions about the ability of Obama and a divided Congress to deal with bigger issues looming down the road, from raising the federal debt ceiling to reining in budget deficits, as the 2012 presidential election campaign gathers steam.

They've got to be laughing at us right now in China, said Senate Foreign Relations Committee Chairman John Kerry. How terrific that the United States of America can't make a decision.

The leadership of the world's lone remaining superpower has been consumed for days by the budgetary infighting that could bring large swathes of government to a standstill.

The White House said a shutdown would idle about 800,000 federal government workers and could slow the U.S. economic recovery. Vital services such as defense, law enforcement, emergency medical care and air traffic control would continue.

Without a deal, many official websites would darken and furloughed government workers would be required to turn off Blackberries. Trash would go uncollected in Washington, and national parks and monuments like the Statue of Liberty in New York would close.

Investment firm Goldman Sachs estimates a government shutdown lasting more than a week could cost the economy $8 billion in missed federal spending, dragging down growth.

AT ODDS

Republican and Democratic aides said negotiators have agreed to $38 billion in cuts but remain at odds over where they would fall. Republicans are resisting a Democratic proposal to cut $1.7 billion from defense.

Obama called House of Representatives Speaker John Boehner, the top Republican in Congress, and Senate Majority Leader Harry Reid, the top Democrat, about the continuing talks.

Reid said the final issue was a Republican push to give states greater discretion over federal funds earmarked for birth control and women's health clinics. Democrats say that would give Republican governors license to block those funds.

Republicans want to shut down the government because they think there's nothing more important than keeping women from getting cancer screenings. This is indefensible and everyone should be outraged, Reid said on the Senate floor.

But Boehner said the final stumbling block was spending cuts that Republicans say are needed to rein in budget deficits hitting $1.4 trillion a year.

We're not going to roll over and sell out the American people like has been done time and time again in Washington. When we say we're serious about cutting spending, we're damn serious about it.

Senate Republican Leader Mitch McConnell said he expected lawmakers to reach agreement on a spending plan and avert a government shutdown.

Fear that a government shutdown could hurt economic growth on the margins pressured the dollar and Treasury prices on Friday. Longer-term, investors are looking at the last shutdown, in 1995, when predictions of spending cuts made government debt and the dollar more appealing and both rose.

Citigroup, the third-largest U.S. bank, noted the budget debate is raising concern among foreign investors about how the government will deal with the budget deficit, federal debt and the budget talks for the 2012 fiscal year, which begins October 1.

The showdown is the biggest test of leadership for Obama, a Democrat, and congressional leaders since Republicans made big gains and took control of the House of Representatives in elections last November.

The confrontation carries big political risks for both parties, who could be seen by voters as failing to make compromises. But Boehner is under pressure to stand firm in the talks from Tea Party conservatives who helped fuel last year's big Republican election gains.

The budget battle has dominated Obama's agenda even as he struggles to balance Americans' chief concerns -- jobs and the economy -- with foreign policy challenges topped by Middle East turmoil and U.S. military involvement in the Libyan conflict.

Reid said Senate Democrats planned to vote on a one-week funding extension that would fund the Pentagon for the year but include no spending cuts to give more time for negotiations. Obama threatened to veto a bill passed by the Republican-led House for a one-week extension that included another $12 billion in spending cuts.

Republicans said they would not allow a vote on a stopgap measure to keep the government operating beyond midnight on Friday unless it contains additional spending cuts.

Any deal reached at this point would require several days to implement, meaning Congress will have to pass some sort of short-term bill to keep the government functioning.

(Additional reporting by Patricia Zengerle, Kim Dixon, Donna Smith, David Alexander, Thomas Ferraro and David Morgan; Writing by John Whitesides and Matt Spetalnick; editing by Will Dunham and Deborah Charles)