The Scottish Government has been urged to "get a grip" over delays to discharging patients from hospitals after the number of delays increased.

A total of 821 patients with non-complex care needs were delayed from leaving hospital in June. In May, 788 patients were delayed from leaving hospital.

Just under 500 patients were kept in hospital for longer than two weeks after having no clinical need to stay. Of these patients, 175 people ended up staying as in-patients for over six weeks.

The Scottish Liberal Democrats have linked the delays to the Scottish Government's handling of the amalgamation of health services with social care.

The party's health spokesperson Alex-Cole Hamilton said the government has to "get a grip" over the situation.

He said: "The integration of health and social care was largely targeted at reducing delayed discharges. But in the months after it went live the figures show that the number of routine cases has increased month on month.

"Hundreds of patients are being forced to stay in hospital weeks longer than necessary because of delays in making care arrangements or a lack of space in residential homes.

"We all want to see the integration of health and social care succeed, but ministers need to get a grip. The last thing we want to see are patients stranded in hospital for weeks longer than necessary. That is bad for patients and it puts unnecessary pressure on NHS staff."

The Scottish Conservatives however criticised the Lib Dems for directly linking the increase to the amalgamation of services.

The party's shadow health secretary Donald Cameron said the problem out dates the move. Cameron called the practice a "nightmare" for patients.

He said: "There's no question the SNP has to do better on bed-blocking. It's a nightmare for both patients and hospitals.

"But it's far too early to say this increase is linked to the integration of health and social care services.

"The problem of delayed discharge far out dates this merger, and pointing the finger solely at this decision risks over-looking other causes."

Scottish Labour said the failure to end delayed discharging is "another broken promise" by the SNP.

Anas Sarwar, the party's health spokesperson, said: "Yet another increase in delayed discharges yet another broken promise from the SNP who promised to eradicate it a year ago.

"Behind every case of delayed discharge is a patient who just wants to get out of hospital and back to their own home.

"Our NHS staff are doing the best they can under the circumstances, but they are over worked, undervalued and under resourced. The lack of funding to health boards and social care from the SNP Government will only make this worse.

"Scottish Labour would guarantee a social care package within a week to ensure that people can be discharged from hospital when they are fit to go home. We would use the new powers of the Scottish Parliament to add a penny on income tax in order to stop the cuts to our public services.

"Faced with the choice between cuts to our public services and using the powers of the parliament the SNP must use the powers."

Last week, Scottish Labour published a document signed off by Sarwar and its leader Kezia Dugdale detailing instances of delayed discharges which it argued showed the SNP is "letting down NHS staff and patients".

The Scottish Government defended its record on delayed discharging of patients.

Health secretary Shona Robison said her government has reduced the practice by 14% from June 2014.

She said: "Good progress is being achieved in reducing delayed discharge, with these latest statistics showing a 6% reduction in the number of bed days lost compared to the same month last year - and a 14% reduction compared to the same month two years ago.

"The number of patients who experienced a delay of over three days has reduced by 9% on the previous year - meaning people are being helped to leave hospital more quickly when there is a delay.

Robinson continued: "Through health and social care integration, the new joint partnerships are now all fully functional. This new way of working will be key to driving further improvements and, with single accountability and joint budgets, partnerships are tasked with making better use of resources that can be tied up in keeping people unnecessarily in hospital."