The Ferguson shipyard in Port Glasgow has been nationalised by the Scottish government.
Ministers will now operate the yard under a management agreement with administrators, which will see the Scottish government buy the facility if no private buyer is found within four weeks.
Ferguson has been involved in a dispute with the Scottish government over the construction of two ferries for CalMac.
About 300 people work at the yard.
The deal means the yard will no longer be owned by industrialist Jim McColl, who could not persuade ministers to pay more than the £97m contract price for the disputed ferries.
The agreement also means work on the CalMac ferries, and other contracts, can continue while efforts to find a commercial buyer get under way.
Administrator Deloitte described the ferry contract as being “materially behind schedule and over budget”.
Finance Secretary Derek Mackay said: “We have always been clear that we want to complete the vessels, secure jobs and give the yard a future.
“Public control will provide much-needed continuity of employment now and ensure the completion of the ferry contracts at the lowest possible cost to the taxpayer.
“It is absolutely essential that the outstanding contracts to build these two ferries are completed.”
Mr Mackay said the alternative was for the government to “stand aside” while the company went into administration, with jobs being lost and the vessels not being completed.
“That was not an outcome I was willing to consider,” he said.
From a bright future to a bitter dispute
When Ferguson Shipbuilders went bust in the summer of 2014 it seemed the last shipyard on the lower Clyde was heading for oblivion.
But within weeks a deal had been brokered for billionaire tycoon Jim McColl to save the Port Glasgow yard.
He was adamant that Scottish shipbuilding could have a bright future. The workforce at Ferguson Marine Engineering Ltd, as it became known, rose from about 70 to 350.
Early work came in the shape of a £97m Scottish government order for two new ferries for CalMac.
And that is where it all started to unravel.
CMAL, the company that owns and manages ferries and other assets on behalf of the Scottish government, was pushing Ferguson Marine hard to complete the ferries on time and on budget.
But Mr McColl was adamant CMAL had made repeated design changes, a claim denied by CMAL, and a bitter dispute ensued with Ferguson Marine last year revealing it expected to lose nearly £40m on the ferry deals.
The Scottish government has made two loans to Ferguson Marine, totalling £45m, and what happens to these, as well as when the ferries will eventually enter service, remains unclear.
Mr Mackay added that developing a revised cost analysis to establish the actions required to complete the two CalMac vessels would be one of the first task undertaken by a new management team.
As part of the agreement with the administrators, the Scottish government will acquire Ferguson Marine if there is no viable commercial offer within the next four weeks.
The GMB union said nationalisation would secure the immediate future of the yard.
The union’s Scotland organiser Gary Cook said: “That is a very welcome development, particularly after all the recent uncertainty.
“Our members were caught in the middle of a situation that had nothing to do with them and their relief will be palpable. It is five years since the yard went bust and the Scottish government has prevented that from happening again.”
Scottish Conservative transport spokesman Jamie Greene MSP said: “The SNP Government’s decision to barge in and use ministerial powers to take over the yard simply covers up the true extent of how much they have messed up this bungled ferry contract.
“We all want to save the yard, save jobs and see these new ferries completed.
“But Derek Mackay has not explored all of the options available, and he has refused to compromise with the shipbuilders over the disputed costs.”
Michael Magnay, restructuring partners at Deloitte, said: “We are grateful for the support afforded to the business by Scottish ministers at what is undoubtedly a very challenging period for all stakeholders, and in particular its employees.
“With this support we will keep the yard operating whilst we proceed to actively market the business for sale, in order to secure its long term future.”
A spokesman for Clyde Blowers Capital (CBC) said: “The Scottish government have not involved CBC or the directors of Ferguson Marine in any of the discussions leading up to this appointment.
“We are unaware of the deal that the Scottish government have made behind the scenes and, as a result, are unable to provide any further comment at this stage.”