The government's ban on sending books to prisoners in England and Wales is unlawful, the High Court has declared.
Under the current rules prisoners are prevented from receiving parcels unless they have "exceptional circumstances", such as a medical condition.
Mr Justice Collins said he could see "no good reason" to restrict access to books for prisoners.
The Prison Service said it was a surprising judgement, and would look at how it would deal with the ruling.
The legal challenge was brought by inmate Barbara Gordon-Jones, who is serving part of her life sentence at Send prison near Woking in Surrey.
The book ban was introduced in November last year in England and Wales, as part of a scheme which limits what prisoners can receive in parcels.
The Incentives and Earned Privileges scheme was brought in partly as an attempt to crack down on drugs getting into prisons.
Prisoners had argued that books sent to them in parcels can be key to their rehabilitation.
Prisoners are still able to read books borrowed from a prison library - and last month the Ministry of Justice relaxed restrictions on the number of books they could keep in their cells.
But it has been claimed that prison libraries are often inadequately stocked, and can be hard to access because there is not always staff available to take prisoners to them.
'Unnecessary and irrational'
Mr Justice Collins said: "I see no good reason in the light of the importance of books for prisoners to restrict beyond what is required by volumetric control and reasonable measures relating to frequency of parcels and security considerations."
He said that the scheme referred to prisoners earning privileges, and added: "In the light of the statement made about the importance of books... to refer to them as a privilege is strange."
A Prison Service spokesman said: "This is a surprising judgement. There never was a specific ban on books and the restrictions on parcels have been in existence across most of the prison estate for many years and for very good reason.
"Prisoners have access to the same public library service as the rest of us, and can buy books through the prison shop.
"We are considering how best to fulfil the ruling of the court. However, we are clear that we will not do anything that would create a new conduit for smuggling drugs and extremist materials into our prisons."
In a statement, solicitors for Barbara Gordon-Jones welcomed the ruling.
"Reading is a right and not a privilege, to be encouraged and not restricted," they said.
"Indeed, Mr Justice Collins commented that, as far as books are concerned, 'to refer to them as a privilege is strange'.
"The policy was unnecessary, irrational and counter-productive to rehabilitation. It is now rightly judged unlawful."
The shadow justice secretary Sadiq Khan described the existing rules as "absurd".
"It had nothing to do with punishing and reforming prisoners but was an example of David Cameron's government's sloppy policy-making," he said.
The Liberal Democrats' home affairs spokesman Julian Huppert said: "We need education in our prisons. It's vital from the moment people walk through the door they get the help and rehabilitation they need to ensure they don't end up back behind bars."
'Responsibility to rehabilitate'
Erwin James, who served 20 years for murder, described the original ban as "outrageous", and said books had helped him in prison.
He told BBC Radio 4's World at One: "I learnt that a good book can change the way you think about life. I was sent books by authors, I was sent books by probation officers.
"I was sent a book called The Grass Arena by John Healy, an amazing book of survival and redemption. You know, it was so important, so important for developing my own thinking and my own understanding of who I was and where I was going."
The rules have been opposed by arts' figures including Poet laureate Carol Ann Duffy, actress Vanessa Redgrave and author Kathy Lette.
A protest was held outside Pentonville Prison in north London in March.
Girl with a Pearl Earring author Tracy Chevalier. who also campaigned against the ban, said she was delighted with the ruling.
She told the BBC: "To me, books are an obvious way to help prisoners. We have a responsibility not just to punish people, but to rehabilitate them.
"Prison is the perfect time to read and to get inside the heads of other people. So that maybe, when you come out, you're more likely to think about other people rather than just yourself."
Author Philip Pullman said: "The ban on sending prisoners books seemed to me strikingly unjust and inhumane. Reading should be a right not a privilege to be withheld or allowed graciously by Her Majesty's government, or anyone else."