HATTIESBURG, Miss. — A judge yesterday freed two men who spent three decades in prison before DNA evidence showed they did not rape a woman and cut her throat in a grisly 1979 attack.

A crowded courtroom erupted in applause after Forrest County Circuit Judge Robert Helfrich’s set aside the men’s guilty pleas, ending a 30-year ordeal for the imprisoned men.

Helfrich said the case was marked by a series of tragic events — from the violent attack on the woman to the years the men spent in prison for a crime they did not commit.

“The common thread in this case is tragedy,’’ Helfrich said.

Helfrich ruled on a petition filed by the Innocence Project on behalf of Bobby Ray Dixon and Phillip Bivens. He will rule later on a posthumous petition for Larry Ruffin, who died in prison in 2002.

The three men were convicted in the 1979 rape and murder of Eva Gail Patterson, whose 4-year-old son watched her be killed.

Dixon, who has lung cancer and a brain tumor, received a medical release from prison last month. He and Bivens were both in court.

“I feel good. I’ve been blessed,’’ said Dixon, who later added, “I was done wrong. I know that.’’

Bivens, 59, simply said, “Thank God.’’ Bivens, who arrived at court dressed in a prison jumpsuit, also said he was ready to return home to California. He was released after the hearing.

Ruffin’s family, wearing blue and gray T-shirts that read “Free at Last,’’ wept and hugged each other. “We just can’t hug him,’’ said his sister, Teresa Strickland, “but he’s free.’’

The victim’s son, Luke Patterson, has always maintained there was a single assailant.

© Copyright 2010 Globe Newspaper Company.