By Ian Chua

SYDNEY (Reuters) - Standard & Poor's on Thursday warned of a downgrade to Australia's coveted triple-A credit rating within two years, saying the knife-edge July 2 election may have weakened the government's ability to tackle its budget deficits.

It cut its outlook on Australia to negative from stable and said there is a one-in-three chance of a ratings downgrade should the government fail to materially improve its balance sheet.

The warning will come as a major blow to Prime Minister Malcolm Turnbull, who is scrambling to gain support from a small handful of independent lawmakers he will likely need to form a workable government and end a political vacuum after an unexpectedly close election.

The Australian dollar initially shed half a cent to a session low of $0.7467 <AUD=D4> after the stable outlook was downgraded by S&P, but has since recovered to be back above 75 cents.

"We will continue to monitor, over the next six to 12 months, the success or otherwise of the new government's ability to pass revenue and expenditure measures through both houses of parliament," S&P said.

Treasurer Scott Morrison said the warning has strengthened his resolve to improve the government's budget position.

"I have no intention of postponing the pace of fiscal consolidation and so therefore I remain very determined to ensure that the warnings that are in this report are not realized," he told reporters.

Analysts expect no lasting market impact from the warning for now. Australia's 10-year bond yields <AU10YT=RR> at 1.88 percent also make the country's debt highly attractive compared to the negative yields of some of its peers.

NO SURPRISE

Shane Oliver, head of investment strategy and chief economist at AMP Capital, said the negative credit watch should come as no surprise.

"Australia has now seen years of slippage in returning the budget to surplus and the messy election outcome threatens more slippage whichever way it goes," he said.

Indeed, S&P said the government's current projection date for a balanced budget by fiscal year 2021, if achieved, would come more than 10 years after the global financial crisis initially pushed the budget into deficit.

S&P last downgraded Australia's credit ratings in October 1989. In May 1999, the agency upgraded the rating to AA+ and in February 2003, it restored the nation's top notch AAA rating where it has stayed since.

On the positive side, S&P said it considered Australia's banking system to be one of the strongest globally and described the country as a "wealthy, diversified and resilient economy".

"The economy's resilience and flexibility, we believe, ultimately help cushion government finances from economic shocks and are a major support to Australia's creditworthiness," it said.

S&P noted economic growth was picking up pace after a period of below-trend performance and estimated headline GDP growth to be around 3 percent in fiscal year 2016, handily beating most of its rich world peers.

Australia boasts an enviable growth track record and hasn't seen a recession in over 25 years.

Earlier in the week, Moody's Investors Service said short-lived political uncertainty in Australia would have limited implications for the country's triple-A rating.

Fitch said Australia's debt profile was still consistent with a triple-A rating but cautioned that political gridlock after an indecisive national election could endanger the top rating over time.

(Reporting by Ian Chua; Editing by Shri Navaratnam)