SNP ministers have handed out millions of pounds of taxpayers' money as part of a furlough scheme to keep a bus manufacturing firm in Scotland.
Alexander Dennis previously said it was considering the potential closure of its two sites north of the border and consolidating them at a single site in Yorkshire, as part of a move that would put 400 Scottish jobs at risk.
But ministers have intervened by agreeing to furlough workers at the company's sites in Falkirk and Larbert - if new orders are made.
The furlough period will begin when a new order is signed and continue until when work begins on it.
Under the agreement, the Scottish Government will pay 80 per cent of staff wages while the company will pay the remainder. The scheme is funded for up to six months.
It is hoped that ongoing discussions surrounding the future of the sites may be swayed by a boost in orders enabled by the Scottish Government's support.
John Swinney, the First Minister, announced the £4m rescue package ahead of a visit to the company's sites on Monday.
To access the funding, the company will have to provide evidence of it getting sufficient orders to allow it to sustain operations in Scotland.
Mr Swinney said the funding was intended to act as a "bridge" to enable the company to continue manufacturing in Scotland.
The furlough scheme could be cut short if work begins earlier than the 26-week limit, the First Minister added.
The package is the culmination of months of negotiations between officials, the bus company and its workers, which have been supported by the trade union Unite.
Speaking to the PA news agency at the company's site in Falkirk, the First Minister said he would "leave no stone turned" in finding a way to keep the company manufacturing in Scotland.
The First Minister said: "I want to do everything I can in whatever circumstance to protect employment within Scotland, and especially manufacturing employment, because that generates significant wealth in the Scottish economy."
He added: "I'm very confident that Alexander Dennis has got a positive outlook on orders and on business, that's a change in situation from earlier on in the year, and what the Scottish Government is providing is essentially a bridge to the future to allow the company to realise and deliver on those orders."
Alexander Dennis would need to secure between 70 and 100 bus orders by the end of the year - as well as between 300 and 400 next year - to be viable, managing director Paul Davies told a Holyrood committee earlier this year.
Responding to the news, he said the announcement marked a "turning point" in its ongoing consultation surrounding the future of the Scottish sites.
The Scottish Government support, he said, would allow the company to propose a "new outcome" within the discussions.
Douglas Alexander, the new Scottish Secretary, welcomed the move and said the UK Government had "actively encouraged" the scheme.
He said: "I warmly welcome Alexander Dennis's decision which will see the company's Falkirk and Larbert sites remain open and operational. This will be a relief to the talented workforce."
"The UK Government has been leading intensive work with partners, including the Scottish Government, and actively encouraged the furlough scheme that has been announced today."
The Scottish Tories welcomed the announcement, but MSP Stephen Kerr urged the Government to ensure the move "protects jobs in the long-term".
He said: "While the SNP have stumped up millions through this scheme, they were missing in action when this firm repeatedly raised the prospect of moving their operations elsewhere.
"Now that taxpayers' money is on the line, SNP ministers must ensure that this protects jobs in the long-term at Alexander Dennis and puts the company in a much better place to win new orders in an increasingly competitive market."
Meanwhile, Unite's general secretary Sharon Graham said: "The immediate priority is now to secure new orders for Alexander Dennis which will protect hundreds of highly skilled jobs for years to come."