By Abhinav Ramnarayan

LONDON (Reuters) - A European Commission ruling that Apple Inc <AAPL.O> should pay Ireland up to 13 billion euros of back-dated taxes could help the country cut its debt significantly but may undermine its government, Standard & Poor's told Reuters on Wednesday.

The European Union's executive arm ordered Apple to pay the bill on Tuesday, ruling the iPhone maker had received illegal state aid.

Although Apple and Dublin have said they will contest the decision, economists have nevertheless been trying to calculate the possible impact on Ireland's finances.

"There are many uncertainties ahead but if we assume that the money will definitely come through, the sum of 13 billion euros is not insignificant for an economy the size of Ireland," Moritz Kraemer, the ratings agency's chief European sovereign rating officer, said.

That figure constitutes more than 5 percent of Ireland's gross domestic product, and if paid would allow the country to bring its debt down to about the mid-80s percent of gross domestic product (GDP) if the government uses it for that purpose alone, he said.

Ireland's debt-to-GDP ratio is around 94 percent, according to Thomson Reuters data.

Apple and Dublin say the U.S. company's tax treatment was in line with Irish and European Union law and they will appeal the ruling, which is part of a drive against what the EU says are sweetheart tax deals usually used by smaller states in the bloc to lure multinational companies and their jobs and investment.

Moody's struck a similar tone to S&P, saying it too would look at both a possible boost to Ireland's finances and the impact on its corporate tax regime, once the appeal was made and the picture was clearer.

(Euro zone ratings factbox)

POLICY WARNING

S&P's Kraemer warned that the ruling might destabilize Ireland's government and its ability to formulate and implement policy -- an important rating factor it looks at.

"If the government chooses not to accept the 13 billion euros at a time when they have stated the money is not there for other spending needs, it could undermine them in the eyes of the public and weaken their position," he said.

Kraemer added that it may be that the Irish business model is being put to the legal test.

"It is clear that if (Finance Minister) Michael Noonan does not want to take the money, then it means he believes it undermines the success of Ireland's economy since the crisis.

"So it might be that the Irish business model is being put to the legal test, and this may not be the end of it -- it may turn out to only be the first example of its nature."

Ireland is rated A+ by S&P, with a stable outlook. Kraemer said that a 13 billion euro windfall on its own would probably not make the agency change the rating.

S&P has upgraded Ireland three times since 2014 from an all-time low of BBB+ hit on the back of a banking crisis that saw Ireland take an international bailout to avoid bankruptcy.

Ireland also has an investment grade rating with Moody's, Fitch and DBRS.

DBRS is due to report on Ireland this Friday, while S&P is scheduled to review it in December.

(Additional reporting by Marc Jones; Editing by Catherine Evans and Alexander Smith)