Courts have dealt with 51 offences of prisoners caught with the highly addictive drug spice as paramedics say they are treating an increasing number of spice-addicted ex-offenders who collapse on the day of their release.

Figures from the Crown Prosecution Service show that there have been 504 offences relating to spice, a form of synthetic cannabis, and other psychoactive drugs since a new law came into force in May 2016 that criminalised their production, sale and supply.

The most common offence was possession with intent to supply or supply (53 times). There were six cases of offering to supply and just one with importing a psychoactive substance.

Short-staffed prisons are struggling to cope with a spice epidemic as prisoners find ever-more ingenious ways to have drugs smuggled into their cells. In December the ringleader of a gang who flew drugs and phones into prisons using drones was jailed for seven years and two months.

Judicial staff at Manchester magistrates court have complained to prisons after defendants have been presented for hearings via videolink clearly high on spice, the Guardian has learned.

One defence solicitor said she had to ask for a trial to be delayed after her client arrived from jail in a catatonic state, having apparently taking a psychoactive drug.

Laura Baumanis, a lawyer for Olliers in Manchester, said the man had been brought to court from HMP Manchester, formerly Strangeways.

“When I went to see him in the cells it was clear that he was unfit to stand trial. It was a really serious concern to me,” she said. “I suspected he was on spice and I couldn’t take coherent instructions from him. He was just staring into space and making very odd gestures.”

One senior paramedic said the ambulance service was seeing a trend in calls from recently released prisoners.

Dan Smith, consultant paramedic at the North West ambulance service in Greater Manchester, said: “What we have is this emerging group from within the prisons. Rough sleepers is one group [of spice users], but ex-offenders are unfortunately becoming addicted or using it during their time in custody and coming out. Sometimes they are new people to us because they have been using inside and then coming out and having to carry on that behaviour because they have that addiction to spice,” he said.

“Sometimes they are on the streets, sometimes they have literally just come out of prison ... we are seeing a bit of a trend of people who have sadly been inside a prison and whether [or not] they were addicted to drugs prior to going in they are now.

“They can unfortunately get access to drugs within the prison system and are coming away with an addiction. I’m sure the prison service are working on the drugs supply within the prison, but we do see those new people sometimes that have been released.”

Sometimes ambulances are called to attend to people on the very day of their release from jail, he added.

Prison staff complain that drugs are increasingly commonplace in jails. In July, 16 prison officers from Holme House prison in County Durham were off work having breathed in smoke blown from prisoners’ cells. A 5.6kg haul of Spice was recovered from the jail.

Home Office data showed drugs were seized almost 30 times a day in prisons in England and Wales last year.

• This article was amended on 27 December 2017 because an earlier version said that the Psychoactive Substance Act 2016 does not make possession of spice a criminal offence outside prison. That was true when the act was passed. After that law came into force, the government classified spice as a class B drug, which made it illegal to possess and sell synthetic cannabinoids. This article was further amended on 8 January 2018 because after publication, the CPS contacted the Guardian to say that the original figures supplied for offences relating to spice were incorrect. These have been corrected.