By Wayne Cole

SYDNEY (Reuters) - An odd mix of policy action in China and policy failure at home is proving an unlikely tonic for Australia's growing budget deficit, perhaps even enough to forestall a near-term downgrade of the country's pristine AAA credit rating

The conservative government of Malcolm Turnbull has been scrambling to placate ratings agency S&P Global Ratings since it changed Australia's outlook to negative in July, promising tighter control on the budget, particularly spending.

It has also had some significant luck: Beijing's drive to clean China's skies and shutter inefficient mines has sent prices of some of Australia's main commodity exports surging.

Spot prices for Australian hard coking coal <.PHCC-AUS=SI> have jumped 230 percent this year to top $258 a tonne. That is a huge windfall for Australia where coal accounts for a tenth of exports at around A$2.8 billion ($2.1 billion) every month.

At first it was thought the spike would be temporary. Indeed, the government is reluctant to incorporate the rises into its mid-year budget review due in December. Yet there are signs the resurgence has legs.

Japanese steel makers have already agreed to double the price of coking coal for the fourth quarter to $200 a tonne. Last week, Glencore <GLEN.L> won an increase of nearly 50 percent in prices for thermal coal to Japan, a contract that covers an entire year.

And it's not just coal. Prices for iron ore, the country's biggest export earner, have topped $64 a tonne compared to a trough last December of $37.

Asian spot prices for liquefied natural gas, another major earner, are up over 50 percent from lows touched in April, again courtesy of rising demand from China.

As a result, Australian export prices jumped 3.5 percent in the third quarter, the steepest gain in five years, and an even bigger increase is likely this quarter.

That will lift national income, company profits and, crucially for the government, the tax take.

Scott Haslem, an economist at UBS, estimates a 10 percent rise in non-rural commodity prices benefits the budget by A$2.2 billion initially, rising to A$5.4 billion after one year.

"At face value, the coal price spike should be positive for the budget, across Federal and State governments," said Haslem. "We think the budget deficits should finally at least avoid slippage, reducing the near-term worry over the AAA rating."

S&P IN A NEGATIVE FRAME OF MIND

Rather embarrassingly for the government, the longer-term outlook for the budget has also improved because it is struggling to get planned tax cuts for large corporations through a divided Senate.

The tax cut was due to cost almost A$50 billion over 10 years but seems certain to be scaled back massively in the upper chamber, radically improving the trajectory of the deficit.

Pressed in a radio interview on whether the Senate was in fact "saving the government from itself", Treasurer Scott Morrison conceded the tax plan now being floated would cost just A$1.4 billion over 10 years.

There is no little irony in this, as S&P had cited the Senate's blocking of government plans as one reason why it cut the outlook on Australia's triple A ratings outlook to negative.

The recent whisper in Canberra was that S&P might not even wait for the annual budget next May, but could downgrade Australia after the government's fiscal update in December.

The agency's review is still ongoing but a taste of its thinking came this week when it cut the outlook on 25 Australian financial institutions to negative, citing rising debt private sector debt and ever-higher house prices.

Yet the sheer scale of the rally in resources could win a respite, says Sean Keane of Triple T Consulting, who works under the umbrella of Credit Suisse.

"Commodity prices are helping to propel Australia away from the ratings downgrade vortex that the country seemed almost certain to slide into at the start of this year."

(Reporting by Wayne Cole; Editing by Simon Cameron-Moore)