MSPs have backed a new law making jail a last resort for suspected criminals despite warnings from victims’ groups that it could put people at “serious risk”.

Holyrood passed the Bail and Release from Custody (Scotland) Bill by 66 votes to 44 as part of efforts to send fewer people to prison on remand and reduce reoffending.

Victim Support Scotland. Scottish Women’s Aid and the domestic violence support service Assist had all pleaded with MSPs to reject the legislation.

But SNP Justice Secretary Angela Constance insisted it contained safeguards and would help tackle historically high levels of prisoners being held on remand.

In April, almost a quarter of Scotland’s 8,000 prisoners were awaiting trial.

The law creates a single new bail test, with courts obliged to explain any bail refusal.

The aim is to make remand a last resort for the court, except in the most serious cases where people are deemed to pose a risk to public safety or a threat to justice.

The law is also intended to reduce the risk of reoffending, ending the scheduled release of prisoners on a Friday or the day before a public holiday so they can access support.

In a statement, Victim Support Scotland, Scottish Women’s Aid and Assist said: “The removal of this safeguard presents a serious risk to the safety of people affected by crime in Scotland, in particular victims of gender-based violence.

“The safety of victims should be at the heart of any decision to release a person on bail.

“The reliance on the new all-encompassing bail test does little to show victims of these types of crime that their safety is being protected under the law.”

But Ms Constance said the new bail test would still “allow a court to remand someone accused of a serious sexual offence or a serious domestic abuse offence, particularly where there has been a track record of offending”.

She added that although the new test stressed remand was a last resort, the Bill made it clear that it was also “necessary where victims’ safety is put at risk”.

The Tories and Labour opposed the legislation.

Tory MSP Jamie Greene, who grew up in a family of domestic abuse, warned the Bill would have “far reaching consequences” by removing a “vital safeguard for victims”.

He said: “It is deeply personal to me. This dangerous bill will inevitably lead to an increase in crime and more victims. Currently, one in four convicted crimes are committed by people out on bail - and this legislation will lead to even more offenders being released from prison.

“The bill ties judges’ hands on sentencing, lets criminals off lightly and endangers victims of domestic abuse.”

Ms Constance acknowledged the concerns of victims’ groups but added: “These reforms recognise that remand will always be necessary in some cases - it plays a vital role in protecting the public and protecting the operation of the justice system.

“However, we know that short periods of imprisonment, including for remand, can be damaging and often disrupt the very things that help prevent reoffending, such as a person’s family life, their health, employment opportunities and housing.

“This legislation delivers on our wider commitment that custody should be reserved for public protection and where someone poses a risk to delivery of justice in a case and that prison should not be used to address wider societal harms.”