Albert Woodfox?s solitary confinement led to an international campaign for his release
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?.
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.
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.
All three were originally imprisoned on armed robbery convictions.
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.