A Somerville man imprisoned for a quarter of a century could be freed soon after a Middlesex Superior Court judge ruled DNA testing supports his claim he did not participate in a 1986 murder, a brutal attack that left the victim to die slowly in the parking lot of an abandoned supermarket.

“He is ecstatic,’’ said Boston lawyer Dana Curhan, who has served as Michael J. Sullivan’s appellate attorney since 1991 through the Committee for Public Counsel Services Innocence Program.

Sullivan was convicted of firstdegree murder in the death of 54-year-old Wilfred McGrath, who was lured to an East Cambridge apartment, where he was robbed of jewelry, money, and cocaine. Beaten but still alive, McGrath was wrapped in a blanket and dumped behind an abandoned supermarket, where his body was found in March 1986, according to court records.

Advertisement - Continue Reading Below

The key prosecution witness was Gary Grace, who had murder charges dropped in return for testifying against Sullivan, records show. Grace testified that Sullivan was wearing a purple jacket at the time of the killing. a State Police chemist testified that blood found on the sleeve of the jacket and hair found in the pocket belonged to McGrath.

But Middlesex Superior Court Judge Kathe M. Tuttman, in an 35-page ruling released Nov. 15, concluded that Sullivan deserves a new trial because DNA testing shows that neither the blood nor the hair belonged to McGrath.

“The Commonwealth presented this blood and hair evidence to the jury as corroboration of Grace’s version of the incident, and, consequently as a link between the defendant [Sullivan] and the victim’s murder,’’ Tuttman wrote.

But “the new evidence that eliminates the victim as the source of the hair and the DNA found on the jacket cuffs also eliminates this link between the defendant and the murder, thus supporting the defendant's theory that he was not present at the time of the murder.’’

Tuttman then ordered a new trial for Sullivan, who faced the prospect of dying behind bars because his earlier appeals of the first-degree murder conviction — which carries life imprisonment without the possibility of parole — have been rejected by federal courts and by Massachusetts’ Supreme Judicial Court.

“With this newly available evidence, the defendant has cast real doubt on the justice of his conviction, and he is entitled to a new trial,’’ Tuttman wrote.

Curhan, McGrath’s attorney, said he has to wait for prosecutors to make the next move, but he will be pushing to have his client, now in his early 50s, released from the state prison in Concord as soon as possible.

“If they decide not to go forward and to accept [Tuttman’s ruling], then he goes home,’’ Curhan said. “He’s been in a long time now. It’s been a hard life for him.’’

In a statement, Middlesex District Attorney Gerard T. Leone Jr., whose office inherited the Sullivan case, said he is reviewing the decision and has not decided on the next step.

“We will review the ruling and all of the materials pertinent to this 1986 murder and 1987 trial to determine what our best course of action is, including whether to appeal the judge’s ruling,’’ Leone said in a written statement.

While Tuttman ordered a new trial because of the DNA evidence, Curhan said there were other problems with the case against Sullivan. While Grace incriminated Sullivan in return for a plea deal, the defense called Emil Petrla, who testified that he and Grace killed McGrath and that Sullivan was not in the apartment.

Curhan said the DNA testing bolsters Petrla’s account. “The government decided who they were going to make a deal with — and I think they picked the wrong guy,’’ Curhan said.

Sullivan’s attorney said the State Police chemist who testified in the 1987 trial was Robert Pino, who was fired by the Patrick administration in 2007 after the discovery that he allegedly mishandled DNA samples at the State Police lab where he worked. In 1987, Pino testified that he found blood on the cuff of Sullivan’s jacket. But the new testing showed no sign of a blood stain, Curhan said.

Pino “may have acted in good faith,” Curhan said, “but I think his work may have been sloppy.’’