The government has been defeated in the High Court over the way it scrapped part of England's school building programme.
The education secretary's decision to axe Buildings Schools for the Future (BSF) projects in six local authority areas was ruled unlawful as he failed to consult on it.
A judge ordered Education Secretary Michael Gove to reconsider the move.
The government said it had won the case on the substantive points.
Mr Justice Holman, sitting in London, allowed the challenges by the councils, declaring that Mr Gove had unlawfully failed to consult them before imposing the cuts.
The challenges related to the revamp or rebuild of 58 schools which, if allowed to go ahead, would have cost the government £1bn.
In five of the six council cases, the failure was "so unfair as to amount to an abuse of power", said the judge.
The councils - Waltham Forest, Luton Borough Council, Nottingham City Council, Sandwell, Kent County Council and Newham - had sought a judicial review on the grounds that the way projects had been stopped was arbitrary and legally flawed.
They asked the judge to order Mr Gove to reconsider the schemes, properly taking account of their merits.
The judge said: "However pressing the economic problems, there was no overriding public interest which precluded consultation or justifies the lack of any consultation."
Mr Gove's decision-making process was also unlawful "because of his failure to discharge relevant statutory equality duties under the Sex Discrimination Act, Race Relations Act and Disability Discrimination Act."
Leader of Waltham Forest Council Chris Robbins said the ruling was "a victory for common sense and fair play".
He said: "They must now make a decision on our funding based on the real evidence about the difficulties our schools face.
"We have said all along that we want to sit down and have an amicable discussion with the government about the difficulties our schools face."
He added: "This slash-and-burn attitude that the government has to local government must end."
Leader of Sandwell Council Councillor Darren Cooper said : "This is not about politics, it has gone beyond that. What we are talking about is the future of our children. I am absolutely delighted for Sandwell."
He added that he believed Mr Gove was no longer competent to make a decision on the future of these schools.
The Department for Education issued a robust defence to the decision. A spokesman said: "On the substantive points he [the judge] concluded that it was a rational decision and that the authorities involved had no expectation of being allowed to proceed with their projects."
He also pointed out that the judge had concluded that "there was no promise or expectation" that any of the claimants' projects would proceed.
The councils had claimed they had a legitimate expectation that the projects would be funded.
The spokesman added: "The Secretary of State will now look again at his decision with regard to these authorities with an open mind, taking representations from them.
"The judge set out, however, that 'the final decision on any project still rests with him and…. No one should gain false hope from this decision.'"
Lawyers for Mr Gove had argued his decisions were not made lightly and were not open to legal challenge.
In written statements put before the court, they said the coalition had inherited "the largest budget deficit in peacetime history", and spending cuts had had to be made "quickly and significantly".
The axing of the scheme in July last year meant that at least 700 school rebuilds in England would not be going ahead.
This sparked an outcry among teachers, councillors and pupils alike, many of whom had worked hard on developing the projects.
But junior education minister Lord Hill said the axing of BSF meant that there would be more money available for school buildings because the programme itself was so wasteful.
He added that the judge's ruling made clear that it only extended to the councils that brought the case.
General secretary of the National Union of Teachers (NUT) Christine Blower said: "The decision by Michael Gove to end the projects was outrageous, particularly in light of the money they are apparently finding to bankroll the free schools programme."
Shadow education secretary Andy Burnham said school building and repair were in complete chaos thanks to Mr Gove.
And he called for a public inquiry into Mr Gove's handling of the decision to scrap the BSF programme.
Ty Goddard, director of the British Council for School Environments, said the key now was to find a system and approach that met the national challenge.
"Much of the school estate is beyond its design life, and pupil numbers are growing," he added.