A county council's decision that 10 libraries should be run by volunteers has been ruled procedurally flawed and unlawful.
Surrey County Council had "failed to have due regard to equality issues", a High Court judge said.
The council said later that it had lost the case only on a "technical" challenge and the legal defeat would not prevent the scheme ultimately going ahead.
The judge is expected to decide next month what orders, if any, to make against the council. It is expected that the authority will have to reconsider its flawed decision in the light of the judgment.
The authority's community library scheme is aimed at keeping its 52 libraries open. It involves removing all paid staff from 10 community libraries, leaving them to be run entirely by volunteers.
The libraries identified as possible community facilities were Bagshot, Bramley, Byfleet, Ewell Court, Lingfield, New Haw, Stoneleigh, Tattenhams, Virginia Water and Warlingham.
Local residents Nicholas Dorrington and Lucy Williams and the Surrey Libraries Action Movement challenged the scheme in judicial review proceedings.
Their lawyers accused the council of failing to comply with the Equality Act 2010 by not paying "rigorous regard" to how the removal of paid staff would affect the accessibility of libraries to vulnerable users, including children, elderly and the disabled.
Allowing their challenge at London's High Court, Mr Justice Wilkie said the council had failed to consider "the nature and extent of the equality training needs of volunteers" when it took its decision last September.
He declared: "In my judgment, the reliance by the defendant on the same bland assertions that training would be required and monitored, as had been contained in the February report, fell substantially short of enabling the cabinet members to give due regard to this obvious equality issue at the stage the process had reached in September."