The firm went into administration earlier this month with the loss of 33 jobs at Springburn, Glasgow, and 118 at Wolverton, near Milton Keynes.
Administrators from BDO said the sale of the business and assets to Knorr-Bremse Rail Systems (UK) Limited had been completed.
The deal will ensure the continuation of works at Railcare's sites and preserve all 202 skilled jobs.
BDO business restructuring partner Kim Rayment 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. This outcome has only been possible because of the support of customers and the dedication of staff, and we are grateful for this cooperation throughout the administration."
Bob Crow, general secretary of the Rail Maritime and Transport union, said: "RMT welcomes any concrete arrangement that will save the jobs and capacity at Railcare's Glasgow and Milton Keynes depots and we will be examining the detail of this takeover to ensure that all jobs and ongoing commitments like outstanding wages and pension contracts are protected.
"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 that all workers caught in this corporate collapse are employed and protected long into the future."
The Scottish Government's Cabinet Secretary for Finance, John Swinney, welcomed the news, adding: "Railcare has a loyal workforce and a healthy order book, and we look forward to the company going forward on a healthy footing.
"Scottish Enterprise has provided account management support to Railcare and we look forward to engaging with the new owners to assist them in consolidating and strengthening their new operation in Scotland."
Unite national officer Julia Long said: "This is very encouraging news and Unite is seeking talks with the new owners at the earliest opportunity. There still remains a number of details which we hope to get clarification on and look forward to a positive working relationship with the company."