NEW ORLEANS — Albert Woodfox, who has spent nearly all of the last four decades in solitary confinement and was facing his third trial for a 1972 murder, was set free Friday as part of a plea deal with Louisiana prosecutors.

Mr. Woodfox, who has long maintained his innocence in the murder of Brent Miller, a 23-year-old prison corrections officer, pleaded no contest to lesser charges of manslaughter and aggravated burglary earlier on Friday before a judge in West Feliciana Parish, about 30 miles north of Baton Rouge.

The sentences on the two counts, added to one for an armed robbery conviction that brought Mr. Woodfox to the Louisiana State Penitentiary in the first place back in 1971, combine for the 45 years he has already spent in prison, and so he was freed on time served. Nearly all of that time he spent in a 6-by-9-foot cell in the penitentiary, which is known as Angola.

Mr. Woodfox left the prison by car shortly before 2 p.m. As the car stopped in front of the prison, he rolled down the window and briefly answered a couple of questions.