Updated

More than 3,000 prisoners in Washington state were mistakenly released early over the past 13 years due to a calculation glitch by the state’s Department of Corrections, leaving officials scrambling to re-incarcerate some inmates and investigate why the problem took so long to correct.

Democratic Gov. Jay Inslee announced the blunder on Tuesday and said he has ordered immediate steps to correct the longstanding computer glitch.

"Frankly, it is maddening," Inslee said.

The problem extends all the way back to 2002, when a state Supreme Court ruling required the Corrections Department to apply good-behavior credits earned in county jail to state prison sentences. However, the programming fix ended up giving prisoners with sentencing enhancements too much so-called good time credit.

The state government said a preliminary analysis indicates as many as 3,200 inmates may have been released early – impacting roughly 3 percent of all releases in that time.

Inslee's general counsel, Nicholas Brown, said most of the errors were 100 days or less. In some cases, inmates were released just a few days early, but at least one person who is still incarcerated had a release date that was off by about 600 days.

Based on a prior Supreme Court ruling, most of the affected offenders won't have to go back to prison. But officials have identified at least seven prisoners who were freed but haven't reached their corrected release date yet, and they will need to return to prison. Five of them have already been re-incarcerated.

The Department of Corrections was first alerted to the error in December 2012, when a victim's family learned of a prisoner's imminent release. The family did its own calculations and found he was being credited with too much time.

A timeline provided by the governor's office shows the agency consulted with attorneys regarding the error the same month and scheduled a fix for the program. However, the coding fix was repeatedly delayed, and the governor says he didn't learn of the issue until last week, when corrections' officials notified his staff.

"For reasons we still don't yet fully understand, that fix never happened," Brown said. Corrections Department Secretary Dan Pacholke, who took over as head of the agency in October and just learned of the error last week, also said he couldn't yet explain what happened.

Brown said officials don't yet have a complete list of prisoners affected. The Corrections Department and governor's office have not released the names of those inmates who have been sent back to prison.

When asked if any of the prisoners who were released early committed additional crimes, Brown said, "We don't have the answer to that."

Inslee told corrections officials to stop releasing prisoners affected by the glitch until a hand calculation is done to ensure the offender is being released on the correct date. A broad fix to the software problem is expected to be in place by early January.

The governor said two retired federal prosecutors will conduct an independent investigation to figure out why it has taken so long to correct the problem.

Pacholke said he welcomed the external investigation.

"The agency should be held accountable for this breach," he said.

Republican state Sen. Mike Padden said the Law and Justice Committee he chairs will convene hearings on the early releases when the Legislature returns to the Capitol in early January.

"We will see what we can find out about this and whether any of these individuals have committed crimes and what crimes they committed when they should have been in prison," Padden said.

The Associated Press contributed to this report.