The US Congress has passed a last-gasp bill to end the partial government shutdown and raise the federal debt limit.

The deal followed a budget fight that has become almost an annual ritual in Washington.

Why did this happen?

There has been repeated political wrangling between the Republicans, who control the lower house - the House of Representatives - and the Democrats, who have a majority in the upper house, the Senate.

Due to disagreements between the two houses over federal government spending, the US Congress failed to pass a budget before the fiscal year ended on 30 September.

Since President Obama's election, the parties have never come to a resolution on a US budget that extends further than a few months. They've just negotiated around the margins and come up with short-term fixes.

Republicans have used these budget deadlines to gain political leverage over contentious policies.

The central issue this time round was Mr Obama's healthcare overhaul, with the Republican-controlled House of Representatives approving budgets eliminating its funding or delaying its central provisions. These were later rejected by the Senate.

This was the first partial shutdown the US has faced in 17 years.

Image caption
Global markets are worried about the prospect of a US default

How did it get so bad?

Paying back US creditors has been a central part of US governance since the time of the nation's founding. In 1790, US Treasury Secretary Alexander Hamilton said, "There can be no time, no state of things, in which Credit is not essential to a Nation."

But since the Democrats ceded control of the House of Representatives to the Republicans in 2010, budget fighting between the two parties has become commonplace.

One big drama came in August 2011, when last-minute posturing by both sides led ratings agency Standard & Poor's to downgrade the credit worthiness of US debt, a historic first.

The debt ceiling has been used as a negotiation point for House Republicans who have sought to extract budget concessions from Mr Obama.

Republicans took their victory in the 2010 House of Representatives elections as a sign that Americans were revolting against Mr Obama's Democratic agenda - and, specifically, that Americans were unhappy with the Patient Protection and Affordable Care Act, or "Obamacare" as Republicans label it.

Republicans vehemently rejected Mr Obama's efforts to overhaul the way healthcare is provided in the United States.

Although past budget fights have included larger questions about the size and scope of the US government, this one was very specifically about Mr Obama's healthcare law, substantial parts of which took effect on 1 October.

Republicans have been doing everything in their power to force Mr Obama to delay implementation of a bill they strongly believe was rejected by the American public.

Mr Obama and the Democrats, for their part, are keen to remind voters that the law was validated by the Supreme Court in June 2012 and was a central issue in the 2012 presidential election, which Mr Obama won decisively.

House Republicans have already voted more than 40 times since the legislation was passed, either to repeal it or to strip its funding.

Who has been affected by the shutdown?

Ten minutes before midnight on 30 September, the White House budget office issued orders for government offices to start shutting down, with workers told to stay at home without pay.

While 700,000 of the 2.1 million-strong federal workforce were initially told to stay home, having been deemed "non-essential" staff, many were back at work before the shutdown ended.

On 7 October, Defence Secretary Chuck Hagel recalled most of the 350,000 Pentagon employees who had been sent home. And the Federal Aviation Administration has reinstated 800 workers.

It's not just government employees who stopped working. Defence contractor Lockheed Martin said it would put 3,000 employees on unpaid leave, and United Technologies' said it would temporarily lay off 2,000 workers.

Most national parks, museums, federal buildings and services closed.

Pension and veterans' benefit cheques have been delayed. Death benefits paid to the families of soldiers recently killed abroad were initially suspended, but restored after a public outcry.

Fears about deadly flu outbreaks and unsafe food mounted, as agencies that typically deal with tracking disease and inspecting food remained mostly dark. Thirty workers at the Centers for Disease Control and Prevention were brought back to work after a deadly outbreak of salmonella.

Child cancer patients have been turned away from drug trials, as doctors at the National Institutes of Health have had to suspend research.

Air-traffic controllers, active military personnel, and border security guards were deemed "essential" and stayed at work.

Workers like teachers, firefighters and doctors continued to be paid, as they are paid for by individual state governments, not the federal government.

What is the likely economic impact?

Ratings firm Standard & Poor's said the partial US government shutdown, the first in 17 years, had already shaved $24bn from the American economy and would cut growth significantly in the fourth quarter.

The US government has experienced 18 shutdowns in the past 30 years, with the previous one lasting 21 days under US President Bill Clinton in 1995, costing the economy over $1bn.

According to recent testimony by US Treasury Secretary Jack Lew, each week the government is shutdown, 0.25% is shaved off economic growth, which was already expected to be a sluggish 2% this quarter.

How was it resolved?

Congress needed to agree to raise the government's $16.7 trillion debt ceiling - the limit at which it can borrow money to pay its bills - by 17 October.

That date was when the US Treasury said it would exhaust the "extraordinary measures" it has been using to pay the nation's bills since the debt limit was hit in early May.

With the deadline looming, Congress eventually voted a deal through.

After a series of failed negotiations, Senate majority leader Harry Reid, a Democrat, worked with the minority leader Mitch McConnell to draft legislation to re-open the government and extend the debt ceiling.

The bill extends the Treasury's borrowing authority until 7 February, and funds the government to 15 January.

But the deal offers only a temporary solution, and does not resolve the budgetary issues that fiercely divide Republicans and Democrats.

Notably, it does not include any Democratic concessions on Mr Obama's healthcare law, which emerges unscathed.

The measure won approval by 81 votes to 18 in the Senate, and then by 285 votes to 144 in the House of Representatives, before being rapidly signed into law by Mr Obama.

Should the world care?

Yes and no.

The longer the shutdown dragged on, the greater the risk to the world's largest economy. That is not good for the rest of the world, which often depends on US consumers.

However, stock markets responded relatively mildly after the shutdown went into force.

Although all three US indexes went down significantly after the shutdown began, news that a debt ceiling deal might be reached sent them all higher. This shows that investors care primarily about a debt deal, not a federal budget.