The money aims to develop intermediate care - helping people stay in their own home instead of going into hospital in the first place - as well as supporting patients to regain their independence and return home sooner after a hospital stay.
It is hoped that by improving the way patients move through hospital and are supported at home, the money will allow them to be moved from accident and emergency (A&E) to an appropriate ward sooner and reduce the amount of unnecessary time spent in hospital.
Health Secretary Alex Neil said: "Our NHS and its partners is making sustainable progress around exploring new and innovative ways to improve the way that patients move through our health and care services.
"We've already legislated for health and social care integration to come into effect from April next year but I am clear that we must make further progress now.
"That's why I'm targeting £5 million today to support the transition to integrated health and social care, and improve patient flow through a number of hospitals and community services.
"This investment will help improve the journey of many patients through hospital and back home supported by appropriate care services so they can leave hospital as soon as they are able.
"Improving flow through hospitals not only benefits the individual patient, but also helps improve the performance in frontline services like A&E and planned operations."
The funding will be targeted in Lothian, Grampian, Fife, Lanarkshire, Highland, Forth Valley and Greater Glasgow and Clyde health board areas.