SNP ministers have been forced to write off almost than £135m of taxpayer loans and investments used to prop up failing companies.

The Scottish Government’s consolidated accounts for 2018/19 show massive write-offs for the Ferguson Marine shipyard, Prestwick Airport and BiFab engineering.

The accounts also show the government underspent its £37bn budget by £778m last year.

Opposition parties said the Government was used taxpayer money "like gambling chips".

The accounts emerged on the same day the Government promoted a new £2bn national public investment bank before a vote by MSPs.

Two loans totalling £45m given to Ferguson Marine in Port Glasgow were reduced to “nil” at the end of the financial year after it went into administration in August.

The spending watchdog Audit Scotland said the Government had "impaired the value of its loans to zero... reflecting its view that the loans were unlikely to be repaid given Ferguson Marine's challenging financial position".

The yard is currently under public control and in search of a commercial buyer, but may be nationalised.

The government also wrote off £33m of the £39.9m it had loaned to Prestwick Airport since taking it over four years ago.

The airport is also up for sale.

An equity stake in the Fife construction firm BiFab that cost the public purse £37.4m was reduced in value to just £2m because of expected losses.

A £21.4m arrangement providing financial guarantees to Lochaber Aluminium Smelter was also reduced to nil to reflect new accounting standards.

The total downgrades came to £134.8m out of £143.7m, putting pressure on SNP finance secretary Derek Mackay to explain his decisions.

It was Mr Mackay who authorised the loans to Ferguson Marine, one for £15m kept secret from parliament for more than six months.

Caroline Gardner, Auditor General for Scotland, said: “The Scottish Government's financial reporting has taken a step backwards at a time when the uncertainty surrounding EU withdrawal will pose unprecedented challenges for the management of public finances.

“Parliament needs better information to be able to better scrutinise ministers' financial decision-making and to ensure value for money is achieved from a limited budget pot."

After auditors also put a health warning on the accounts of the new Social Security Scotland benefits agency because of Carers’ Allowance, Ms Gardner added: "There is a lot more work to be done to manage Social Security Scotland's current reliance on the DWP.

“More complex and costly benefits are due to be delivered by the agency over the next few years, which increases the potential impact of error and fraud. The agency needs to think about what arrangements will be needed to manage that scenario."

In a statement on the accounts, Mr Mackay failed to mention the write-offs.

He said: "For the 14th consecutive year, the Scottish Government’s accounts were given a clean bill of health by Audit Scotland, who highlighted our budget management was effective in managing total spending within the limit set.

"We continue to operate in a challenging financial climate as Brexit, and the increasing risk of a ‘no deal’ scenario, remains the biggest threat to our economy and public finances as we take steps to try and mitigate the impact of such an outcome.

"Under the current devolution settlement, the Scottish Government is not permitted to overspend its budget. As a consequence, we have consistently adopted a position of controlling expenditure to ensure we live within the budget caps that apply, while maximising spending on public services. Any money which is underspent in a financial year is carried forward in full into the next year and is invested in public services.”

Tory MSP Murdo Fraser said: "The Scottish Government complains endlessly that they don’t have enough money to spend and blames the UK Government at every turn.

“Now we learn that £135m has just had to be written off due to failed investments.

“This is a staggering waste of public money which is entirely in keeping with Derek Mackay's total failure to manage Scotland’s public finances.

“He is, quite simply, out of his depth."

Scottish LibDem leader Willie Rennie said: "The auditor is savage in criticism of the Scottish Government for its financial planning.

“People will be surprised that SNP have been able to write off hundreds of millions of pounds of loans without even having a clear framework for how it treats private companies.

“Ministers are using taxpayers’ money as gambling chips but never seem to have to face the music when the deal goes wrong.

“It is time for the SNP to stick to a more rigorous financial strategy that respects the tax revenues with which they have been entrusted.”

Responding to the Auditor General's report, a Scottish Government spokesperson said later: "The Scottish Government’s support for private companies has protected hundreds of jobs and ensured key economic assets have been saved from closure.

“There is an extensive framework of legislation, economic policy, procedures, practice and expertise that guides and supports sound decision-making on financial interventions involving private companies. We have also published new guidance this year that specifically relates to investment in businesses by Scottish Ministers. 

“As our accounts make clear, where Scottish Ministers decide to make investments directly through the Scottish Government, Accountable Officers must ensure that appropriate diligence and consideration is carried out before any commitment is made to invest.”