BOSTON — The highest court in Massachusetts has upheld a ruling granting a new trial to a man who spent more than three decades in prison after he was convicted of starting a 1982 fire in Lowell that killed eight people, including five children.

A Middlesex Superior Court judge overturned Victor Rosario’s murder and arson convictions in 2014. The judge cited developments in fire-science investigation and questions about whether Rosario’s confession was voluntary.

Prosecutors appealed that decision. In its ruling Thursday, the state Supreme Judicial Court agreed with the lower court judge, finding “a confluence of factors combined to create a substantial risk of a miscarriage of justice.”

Middlesex District Attorney Marian Ryan must decide whether to re-try Rosario. A spokeswoman said Ryan is reviewing the ruling and will make a determination.