A CREDIT ratings agency has warned the UK's top-ranked AAA status has been put at risk because of the decision to hold an in/out referendum on European Union membership.

Standard and Poor's said the Tories' commitment to a public vote on whether to remain in the EU by 2017 could "complicate" the relationship between Scotland and the rest of the UK.

It warned that continuing with the move while also delivering a new constitutional settlement devolving wide-ranging powers to Scotland was "ambitious", and could threaten the UK's top-ranked AAA status.

The agency warned that economic policymaking "could be at risk" of being more exposed to party politics than previously anticipated, and has downgraded the outlook from "stable" to negative".

"A possible UK departure from the EU also raises questions about the financing of the economy's large twin deficits and high short-term external debt," it said in a statement.

"We are therefore revising the outlook to negative from stable," it concluded - meaning at least a one-in-three probability of a downgrade over the next two years.

It warned that the downgrade could be a dramatic one if the UK appeared on course for a so-called "Brexit".

S&P said its decision to maintain the AAA rating "reflects our opinion that the UK continues to exhibit high labour- and product-market flexibility, and a wealthy and diversified economy".

It is the only one of the major ratings agencies still to give the UK the highest rating.

But it said David Cameron's promised referendum "represents a risk to growth prospects for the UK's financial services and export sectors, as well as the wider economy".

And the "ambitious" intention to renegotiate the UK's relationship with Brussels - at the same time as securing a new devolved settlement for Scotland - "may well take precedence over other policy imperatives, such as how to address the supply bottlenecks in UK infrastructure and in the housing market".

SNP MP and Europe spokesman Stephen Gethins said that Westminster should heed calls to give Scotland a veto on an EU exit if Scots vote to stay in the EU while the UK votes to leave.

He said: "A Brexit would have a grave impact on jobs and the economy in Scotland - and would send entirely the wrong message about our place in the world. For Scotland to be taken out of the EU if we vote to stay in would be democratically indefensible.

"The SNP's common sense amendment for a double-majority safeguard will ensure Scotland cannot be ripped out of the EU against our will, and it must be included in the UK Government's Bill."

A Treasury spokesman said that the confirmation of the UK's AAA was a "clear endorsement" of the Government's long-term plan.

He said: "We've cut the deficit in half, have more people in work than ever before and have seen the fastest growth of any major European economy over the past year.

"We are the first to say that this is a time of heightened risk that threatens the recovery, which is why we need to go on working through the plan that is delivering economic security.

"Central to that plan is giving the British people their first say on our EU membership in 40 years and resolving the uncertainty around Britain's relationship with the EU.

"In doing this, we are seeking economic reforms that will deliver long term prosperity for the working people of Britain and the rest of Europe."