Image caption The UK's top rating has been under threat for several months

Standard & Poor's (S&P) has become the last of the three main rating agencies to put the UK's top AAA rating on "negative outlook".

S&P said it could lower the UK's rating "if fiscal performance weakens beyond our current expectations".

Fellow agencies Moody's and Fitch both revised the UK to negative outlook in the first half of this year.

The Treasury pointed out that S&P endorsed the government's "strong commitment" to reducing the deficit.

"It is a hard road, but the economy is on the right track and just this week it was again confirmed that jobs are being created, with over one million private sector new jobs in the last two years," a Treasury spokesperson said.

A country's credit rating can influence its borrowing costs, as some investors are restricted from lending to borrowers that do not have a high rating.

The UK, Germany and Canada are the only major economies to currently have a top AAA rating.

"The outlook revision reflects our view that we could lower the ratings on the UK within the next two years if fiscal performance weakens beyond our current expectations," S&P said in a statement.

"We believe this could occur in particular as a result of a delayed and uneven economic recovery, or a weakening of political commitment to consolidation.

"We expect economic growth to rise slowly in the medium term, with net general government debt as a percentage of GDP [annual economic output] continuing to rise in 2015, instead of stabilising in 2014 as previously expected."

The UK is expected to have a budget deficit of 7% of GDP this year, well down on the 11% seen at the peak of the financial crisis.

Its net debt, excluding interventions to support the banking sector, is forecast to keep rising and peak at 80% in the 2015/16 tax year.

Damage?

S&P also revised its outlook on the Bank of England's AAA rating to negative.

A downgrade of a credit rating does not necessarily substantially damage the ability to borrow.

The US was downgraded from its AAA rating last year, a move that has not materially changed its borrowing costs.

Some analysts suggested a downgrade could do some mild damage.

BNP Paribas economist David Tinsley said: "2013 looks like being a year when the UK could lose its AAA rating fairly comprehensively.

"Some of the safe-haven glow of the UK is looking a bit tarnished."

Others said that sales of government bonds, whose price in theory is guided by credit ratings, had been quietly slipping.