Judge James Brady also banned prosecutors from trying Albert Woodfox, 68, for a third time.
He has been in solitary confinement since 18 April 1972 after a prison riot that resulted in the death of a guard.
Woodfox was tried twice for the guard's death, but both convictions were later overturned. He denies all the charges.
On Monday, Judge Brady ordered the unconditional release of Woodfox and barred a third trial, saying it could not be fair.
But a spokesman for the Louisiana attorney general said prosecutors would appeal "to make sure this murderer stays in prison and remains fully accountable for his actions".
- 80,000 prisoners estimated to be in solitary confinement in the US
- Held in 44 states, 25,000 in "supermax" jails
- Conditions vary, but can include up to 23 hours a day confined alone
- Psychologists warn of negative reactions, such as isolation panic
- UN torture rapporteur wants global ban in all but exceptional circumstances
- Proponents say needed to protect other prisoners and staff
Sources: ACLU, Bureau of Justice Statistics. Solitarywatch.com, Louisiana Prison Watch
Woodfox is one of three men who were held in solitary confinement at the maximum security Louisiana State Penitentiary and known as the Angola Three, as the prison lies next to a former slave plantation called Angola.
The other two men, Robert King and Herman Wallace, were released in 2001 and 2013 respectively. Wallace died soon after his release pending a new trial. King's conviction was overturned.
All three were originally imprisoned on armed robbery convictions.
Woodfox and Wallace were involved with the Black Panthers, a militant black rights movement formed in 1966 for self-defence against police brutality and racism, which later embraced "revolutionary" struggle as a way of achieving black liberation.
Woodfox, Wallace and King consistently maintained they were imprisoned for crimes they did not commit, with convictions only obtained after blatant mistrials.
King, who spent 29 years in solitary confinement, described his experience to the BBC in an interview three years ago.
He said he remained strong but it was "scary" to see how others crumpled through lack of human contact.
The three men have been the focus of a long-running international justice campaign.