Emergency services were called out more than 26,600 times - or every 20 minutes on average - to incidents in UK prisons last year, the BBC has learnt.

Figures suggest a 52% rise in emergency services callouts since 2011.

The chief inspector of prisons in Wales and England said drugs had a "draining effect on other services". He added "many jails were not fit for purpose".

The Prison Service said "a significant number" of emergency services callouts were for "non-violent incidents".

The BBC asked all 109 UK police forces, ambulance trusts and fire services how many incidents they had been called out to at prisons and youth detention centres each year between 2011 and 2015.

Of the 91 services that supplied full data for all years (excluding those who had no prisons within their jurisdiction), there had been a 52% rise in callouts, from 14,475 in 2011 to 22,055 in 2015.

'Community problem'

Chief inspector of prisons Peter Clarke, commenting on the issue of drugs within jails, said: "The impact that these drugs are having is not, of course, limited simply to within the prison walls.

"It has an enormously draining effect on other services, particularly the ambulance service.

"We know of instances where at least one ambulance service has had to declare a major incident in order to respond to a number of people falling very ill as a result of taking these drugs.

"It's not just a problem for the Prison Service, it's a problem for the whole community."

Number of items thrown into prisons doubles in two years

Image caption The BBC has obtained footage of a fight in a prison exercise yard that led to an air ambulance being called

Mr Clarke also told the BBC that some prisons were "not fit for their purpose".

"If the purpose is to keep people safe in custody... then some of them are failing, undoubtedly," he said.

"If the purpose is to develop an environment in which meaningful rehabilitation and resettlement can take place, then again some of these prisons are failing."

Legal highs - due to be banned in the UK within weeks under the Psychoactive Substances Bill - are psychoactive drugs that contain various chemical ingredients, some of which are illegal while others are not.

They produce similar effects to illegal drugs like cocaine, cannabis and ecstasy.

Heart attacks

Kyron Skerritt, who served four years in three different prisons, said he believed the use of so-called legal highs, such as spice, inside prisons had fuelled emergency services callouts.

"People were literally getting heart attacks and ambulances were coming in every couple of days," he said.

"Sometimes you'd see three ambulances outside because of the amount of drugs that's come in from all different parts."

Another former prisoner, who wished to remain anonymous, estimated that 70% to 80% of prisoners were smoking spice.

"Ambulances are getting called daily to different wings outside because of heart palpitations - their [hearts] are racing."

Image caption Kyron Skerritt said prisoners had had heart attacks after using legal highs

The increase in callouts over four years broke down as a 104% rise for ambulance trusts, 65% for fire services and 21% for police forces.

More than one emergency service may have been called to the same incident and some callouts did not end in a deployment; some would be dealt with on the phone or judged to not require a visit.

The Prison Service said: "A significant number of emergency services callouts are for non-violent incidents, including where they attended as a precaution and when the situation was resolved by prison staff."

It added that it recognised the prison system needed reform.

"We need to give governors greater freedoms to innovate to find better ways of rehabilitating offenders. We must do better at reducing violence and preventing drugs entering prison."