California’s prison system will release an estimated 3,500 inmates early to keep the novel coronavirus from spreading behind bars, state officials announced Tuesday.

The state Department of Corrections and Rehabilitation said the first batch of nonviolent prisoners will be released to parole up to 30 days early, while the next group will be released up to 60 days early. Ineligible for early release are violent offenders, sex offenders and those serving time for domestic violence.

“We do not take these new measures lightly. Our first commitment at CDCR is ensuring safety — of our staff, of the incarcerated population, of others inside our institutions, and of the community at large,” said Ralph Diaz, secretary of the corrections agency. “However, in the face of a global pandemic, we must consider the risk of COVID-19 infection as a grave threat to safety, too.”

State officials assured all victim notification requirements will be met.

Orange County District Attorney Todd Spitzer railed at the early release decision, saying all state inmates are dangerous.

“This will become the slippery slope for everybody,” Spitzer said. “If they’re doing it at the state level, they’ll do it at the county jails. … That’s why gun sales are going up.”

Orange and Los Angeles counties also have early release programs at their jails because of the threat of COVID-19.

The efforts will provide more space to spread the remaining prisoners within social distancing recommendations. Open spaces in the prisons, such as gymnasiums, will be used to expand capacity. As of Monday, 22 prison employees and four inmates have tested positive for COVID-19.

The state already has taken extensive measures to protect staff and inmates, including mandatory medical screenings for anyone entering the institutions, prison officials say.

The prisons also have stopped accepting inmates from county jails, which is projected to reduce the prison population by 3,000 within 30 days.

Visitations have been suspended and free phone calls are being provided to family and friends.

More soap and hand sanitizer also are being handed out.

The department also will immediately expand space in community-based parolee programs, particularly for those at risk of homelessness or housing instability. Additionally, the department has been in communication with its county partners regarding these measures and will coordinate with them to promote a successful reentry for parolees.