More than 70 workers at the Railcare plant in Springburn, Glasgow, will be retained following the takeover by Knorr-Bremse Rail Systems Ltd, with the new owners also agreeing to pay employees the July salary they missed out on when the company was plunged into crisis.
Administrators BDO confirmed that the sale of the business and assets had been completed on Monday.
The deal will also preserve more than 100 jobs at Railcare's sister factory in Milton Keynes.
Unite, which represents workers at the site, is also seeking urgent talks with representatives of Knorr-Bremse in a bid to have the 33 employees who were made redundant when the firm went into administration earlier this month reinstated to their posts.
Bryan Jackson, business restructuring partner at BDO, said: "The sale of Railcare's business and assets to Knorr-Bremse will secure a future for the business and jobs.
"Under the conditions of the sale Knorr-Bremse has agreed to pay retained employees their July salaries, which Railcare was unable to provide before it entered administration. Current employees will therefore be paid for all work they have done to date.
"We are delighted with this very positive outcome for the business, employees and more broadly for the communities of Wolverton and Springburn, both of which have strong railways heritage."
The depot is Scotland's last remaining railway workshop, which under British Rail ownership employed some 4000 workers and exported locomotives to all corners of the empire.
Today it provides servicing and repairs to rolling stock belonging to a number of train operators, including First ScotRail.
Eddie Duffy, Unite organiser at the factory, said: "We are seeking a meeting with the new owners at the earliest possible opportunity and wish to see the 33 skilled workers made redundant by the failures of the UK Government reinstated into their posts."
RMT, which also represents Railcare workers, had blamed the crisis - said to amount to a £1 million cash-flow shortage - on delays caused by last year's aborted West Coast franchise bid, which held up fleet refurbishment plans.
General Secretary Bob Crow welcomed the sale of the company to Knorr-Bremse, adding that the union would be seeking assurances that outstanding wages and pension contracts are protected.
Mr Crow said: "RMT has also not forgotten the savage treatment handed out to those Railcare staff already made redundant and we will be pressing for arrangements to ensure all workers caught in this corporate collapse are employed and protected long into the future."
Springburn MSP Patricia Ferguson said: "This ends weeks of uncertainty for the skilled staff of the company and hopefully means that they will have a stable future. Clearly we need to look at the deal that has been done to ensure that it is sustainable and can support the continuation of engineering works at both sites."
Cabinet Secretary for Finance, John Swinney, added: "Railcare has a loyal workforce and a healthy order book. We look forward to the company going forward on a healthy footing."