The plans for the development on the Hatchfield Farm estate in Newmarket, Suffolk, had been approved by Forest Heath District Council.
But last year Local Government Secretary Sajiv Javid refused to accept the decision.
Planning judge Mr Justice Gilbart ruled that Mr Javid's decision was fatally inconsistent and "plainly deficient".
The case will now have to be reconsidered.
Mr Justice Gilbart, sitting in London, quashed the refusal, saying: "The secretary of state has performed a complete and unexplained volte-face in his assessment of the highways impacts of two proposals for development on the same site in Newmarket and has also failed to apply his own National Planning Policy Framework."
The judge said: "There is on any view a requirement for more land for housing and other economic development in the Forest Heath District."
Edward Stanley, the 19th Earl of Derby, brought the legal challenge with Moulton Parish Council and the Rural Parishes Alliance.
The judge said local parish councils had for some time argued that growth in the area should not be dispersed among the rural parishes but concentrated in Newmarket.
Newmarket Horsemen's Group and some others were concerned that development in the town "may have an adverse effect on the horseracing industry that is based there" and lead to increased traffic.
A spokesman for Lord Derby said: "The secretary of state now has a second chance to determine the application. He should take full account of the significant benefits the planning application will bring to Newmarket when making a decision."
The Department for Communities and Local Government said: "We have received this judgment and will now consider our response."
Lord Derby has won a key High Court stage of his fight to build 400 homes on his land.