A conservation group has won a legal battle to force Fife Council to rethink its plans for a new £40m school on green belt land south of St Andrews.

The challenge brought by St Andrews Environmental Protection Association (Stepal) against the council's decision to approve in principle a site at Pipeland Farm for the new Madras College has been upheld by three civil appeal judges.

Lord Malcolm said the decision would be quashed as "unlawful" and the whole matter would be sent back for reconsideration.

The judge said: "When a council is both applicant and planning authority, it will not always be easy for planning officers, councillors and others to separate and safeguard its planning jurisdiction from its interest in the proposed development."

Lord Malcolm, who heard the appeal with Lord Drummond Young and Lady Clark of Calton, said the planning authority had adopted "an erroneous approach".

The proposal for the new secondary school is a joint venture between St Andrews University and Fife Council on university land.

A spokeswoman for Stepal said: "We are pleased at the decision of the Inner House at the Court of Session which was announced today.

"This vindicates the original recommendation of the north east Fife councillors to reject the Pipeland Farm plan at the start of this process.

"Stepal recognises the concern of parents, pupils and staff to resolve the long standing need for a first class replacement Madras College in the right place."