He had been one of the “Angola 3,” convicts whose solitary confinement at the Louisiana State Penitentiary in Angola, an 18,000-acre prison farm on the site of a former plantation, became a rallying point for advocates fighting abusive prison conditions around the world.       

Mr. Wallace was serving a prison sentence for armed robbery when the correctional officer, Brent Miller, was stabbed to death in a riot at Angola in April 1972. Mr. Wallace and two other men were indicted in the killing. Two of the three — Albert Woodfox and Mr. Wallace — were convicted in January 1974.       

They were placed in solitary confinement, joining another prisoner there, Robert King, who had been convicted of a different crime, and for decades to follow they were locked up for as much as 23 hours a day. Amnesty International published a report on them in 2011, and they were the subject of a documentary film, “In the Land of the Free,” directed by Vadim Jean.       

In the film, Teenie Verret, the widow of Brent Miller, said of the killing, “If they did not do this — and I believe that they didn’t — they have been living a nightmare.”       

George Kendall, who was a lawyer for Mr. Wallace and who confirmed the death, said in an interview that his client’s original conviction was “a travesty” based on shoddy evidence, and that the men had been kept in solitary confinement because they had been members of the Black Panthers, the black nationalist group. Officials worried “that they would organize the prison,” he said.       

Even from solitary, Mr. Wallace worked to improve prison conditions and to press his own appeals, Mr. Kendall said. He answered mail from people who had heard about his case.       

“It was a determination he would not be broken by the loneliness of the cell,” Mr. Kendall said.       

Mr. Wallace gained further attention for a project that he embarked on with Jackie Sumell, an artist who had struck up a correspondence with him and asked him to describe his “dream house.” She then rendered his imaginings into a scale model of the house, which became an art installation seen in galleries in a dozen countries.       

The project, Mr. Wallace had said, “helps me to maintain what little sanity I have left, to maintain my humanity and dignity.” A documentary film about the project, “Herman’s House,” was shown on PBS in July.       

Herman Wallace was born on Oct. 13, 1941, in New Orleans, the fourth of eight children. His mother, Edna Clark Williams, worked in the Orleans Parish Prison. She died in 1996. He is survived by his longtime partner, Maria Hinds, and five sisters: Victory Wallace, Lorraine Anderson, Barbara Marshall, Justina Williams and Darlene Williams.       

Mr. King was released from prison in 2001; Mr. Woodfox is still in prison in Louisiana.       

Mr. Wallace’s cancer was detected in June, his lawyers said. On Tuesday, Chief Judge Brian A. Jackson of the United States District Court for the Middle District of Louisiana ordered that Mr. Wallace be released from prison and said he could be retried.       

The original indictment, he wrote, was fatally flawed because women had been excluded from the proceedings in which the grand jury was picked. Judge Jackson threatened to hold prison officials in contempt if they failed to release Mr. Wallace immediately.       

“He has spent more than 40 years in prison under a conviction and sentence based on an unconstitutional indictment,” the judge wrote. “By any measure, the time remaining on Mr. Wallace’s life sentence is far less than he has already spent in prison.”       

On Tuesday, Mr. Wallace was released from the Elayn Hunt Correctional Center in St. Gabriel, La. He was moved by ambulance to the home of a friend and supporter, Ashley Wennerstrom, a program director at the Tulane University School of Medicine.       

Though Mr. Wallace was weak, drifting in and out of consciousness, Ms. Sumell said, “He was very well aware of the fact that he was in Ashley’s home, and he was a free man.”       

On Thursday, Mr. Wallace was indicted again. Samuel C. D’Aquilla, the district attorney for East and West Feliciana Parish, said in an interview that he believed that the evidence originally used to convict Mr. Wallace remained sufficient to convict him again.       

“We just felt that he was a murderer,” Mr. D’Aquilla said, adding, “I know he was old, I know he had medical problems, but when he committed a murder, he didn’t have medical problems.” Brent Miller, the murdered prison guard, he said, “didn’t get another chance.”       

As Mr. Wallace lay dying, his friends at the Wennerstrom house did not speak of the indictment as they held a bedside vigil.       

“One of the final things that Herman said to us,” his lawyers said in a statement, “was, ‘I am free. I am free.’ ”