Up to 450 prisoners are to be released early to prevent the spread of coronavirus after the Scottish government approved the move.
Justice Secretary Humza Yousaf said the legislation was designed to free up more cells for single-use occupancy to help limit the number of cases.
Only those who have been sentenced to 18 months or less and have 90 days or less left to serve will be eligible.
Restrictions will also be in place to exclude certain groups of prisoners.
Mr Yousaf said: "Scotland's prisons have implemented significant changes in recent weeks, ending family visits and limiting time spent out of cells, and I am extremely grateful to the dedication and professionalism of all those working in such challenging environments.
"By releasing a number of short-term prisoners a few weeks - and at most 90 days - ahead of their due release date, we will ensure there is capacity to safely manage the still large number of people in custody across the prison estate."
The justice secretary said the measures would be subject to a "triple lock" set of restrictions.
He added: "Firstly, our emergency legislation, already passed by parliament, automatically excludes those in prison for the most serious crimes, including sexual or terrorism offences.
"Secondly, the subsequent regulations now exclude anyone who is serving a prison sentence for a Covid-19-related offence, or is currently or has recently been imprisoned for domestic abuse.
"Thirdly, each prison governor will have a veto over the release of any otherwise eligible prisoner if they have a concern for the safety of an identified individual in the community."
Mr Yousaf stressed the move was designed to protect prison officers and NHS staff, as well as inmates across the country.
Last month a prison officer at HMYOI Polmont became the first in the country to die with the virus.
The inmates will be released gradually from custody over the next 28 days.
Days after the lockdown was implemented, the justice secretary described the situation in Scotland's prisons as "increasingly alarming".
Almost six weeks on he said the decision had not been taken lightly and did not diminish the experiences of victims of crime.
Howard League Scotland, an independent penal reform organisation, welcomed the move but said it would only reduce the prison population by 5%.
A spokeswoman said: "Covid-19 has changed our behaviour and thinking in ways we could never have envisaged and so this emergency release shouldn't be seen as a measure of anything like the same magnitude as shutting schools or restricting travel.
"It's a sensible first step which has been taken to ease the intolerable pressure in Scotland's prisons and to avert a public health crisis."