An alliance of hundreds of pupils and schools and scores of local councils, as well as teaching unions, have lost their unprecedented legal challenge over GCSE English exam grades.

The alliance, which included Southampton City Council, accused the AQA and Edexcel exam boards of unfairly pushing up the grade boundaries for English last summer in what amounted to ''illegitimate grade manipulation'' and ''a statistical fix'' involving exams regulator Ofqual.

But two judges at London's High Court today dismissed the challenge.

Lord Justice Elias, sitting with Mrs Justice Sharp, said Ofqual had appreciated there were features which had operated unfairly and proposed numerous changes for the future designed to ensure problems that had arisen would not be repeated.

The judge said: ''However, having now reviewed the evidence in detail, I am satisfied that it was indeed the structure of the qualification itself which is the source of such unfairness as has been demonstrated in this case, and not any unlawful action by either Ofqual or the AOs (exam boards)''.

The judges were told at a hearing in December that an estimated 10,000 pupils who sat exams in June last year missed out on a C grade - the minimum grade normally needed to go into further education.

Clive Sheldon QC, appearing for the alliance, said the lower grades were not the fault of the students, who had ''worked well and hard''.

He said the evidence of unfairness was overwhelming.

Ofqual had given an instruction to avoid ''grade inflation''.

Bodies awarding grades were required to meet tolerances based on statistical predictions derived from students' performances in Key Stage 2 examinations five years previously.

The predictions, which were used as a ''straitjacket'' rather than as a guide, were that too many students were going to get a C grade or better in GCSE English, said Mr Sheldon.

A decision was taken to push up grade boundaries for the exams marked in June to bring down the numbers of good grades for the year as a whole.

Mr Sheldon said that had resulted in students being unjustifiably ''clobbered'' to meet the Ofqual requirement of no apparent grade inflation.

He argued the ''gross manipulation'' that took place amounted to ''conspicuous unfairness and an abuse of power''.

Schools, teachers and students had reasonably expected that those sitting the June examinations would be treated consistently with students who had earlier taken papers and submitted controlled assessments, argued Mr Sheldon.

He said the June students should be put in the position they would have been in had the grade boundaries in January been applied to them.

Lord Justice Elias dismissed the alliance's application for judicial review, but said the issue had caused an outcry and was ''a matter of widespread and genuine concern properly brought to court''.

The judge said Ofqual, following the outcry over the grades, ''was not persuaded that it should require the grade boundaries to be changed, but it appreciated that there were features of the process which had operated unfairly and it proposed numerous changes for the future which are designed to ensure that the problems which arose in this case will not be repeated.

''It also took the unusual step of allowing students to take resits in November instead of having to wait until the following January.''

Mrs Justice Sharp said she agreed that the alliance application should be dismissed.

Joan McVittie, headteacher of Woodside High School in north London, which was part of the alliance, and past president of the Association of School and College Leaders (ASCL), said: ''We are bitterly disappointed. This case was taken on behalf of young people who were affected last summer.

''This has affected their life chances considerably.''

She argued the judgment had stated there had been unfairness for children, but that Ofqual had acted within the law.

''That is a hard lesson for children to learn,'' Mrs McVittie said.

She added: ''This was about the law and it wasn't about fairness.''

Ofqual chief regulator Glenys Stacey said: ''We welcome the decision of the court that, faced with a difficult situation, Ofqual did the right thing and the fairest thing, for the right reasons.

''It's clear from the judgment that if we had followed the course of action called for by the claimants, the value of GCSE English would have been 'debased', to use the judge's word, and many students would have received grades that they did not deserve.

''We know some students and schools will be disappointed with this. We understand that. But it's our job to secure standards.'' Mrs McVittie later added: ''Throughout the judgment they've used terms like unfairness and unfairness in the system.

''How do you explain that to a 16-year-old who can't get a job because they haven't got a C grade?''

Sir Steve Bullock, Mayor of Lewisham Council, which was part of the alliance, said: ''This is a very frustrating outcome.

''We note that the judge accepted that the case exposed unfairness and that it was right that this was properly investigated in the court room.

''But that is no consolation for the thousands of students up and down the country who will have to continue to live with the consequences of this unfairness. We wish them every success in the future.''

Russell Hobby, general secretary of the National Association of Head Teachers (NAHT), said the union was ''very disappointed'' with the decision.

''Grading decisions were unfair and an injustice was done to many thousands of pupils. While boundaries have not been restored, we hope this action will demonstrate to Ofqual and the exam boards that they should not act like this again.''

Christine Blower, general secretary of the National Union of Teachers (NUT), said: ''It is very clear to the NUT and the other organisations who brought this action that a great injustice has been done.''

Rod Bristow, president of Pearson UK, which oversees the Edexcel exam board, said: ''We understand this has been a time of uncertainty for students, teachers and parents. We are pleased that the courts have investigated the evidence thoroughly and found that our awarding processes were rigorous and fair.

''Yet there is much to be learned from the events of this summer. We will now focus on working even more closely with the regulator, government, higher education and employers to secure the confidence of students, parents and teachers in the values and standards of our exam system.''

A spokeswoman for the AQA exam board said: ''The court has confirmed that we set the right grade boundaries for GCSE English last summer. The judges found that the boundaries reflected the standard required to achieve those grades, based on academic judgement. In the judges' view, the main reason schools did not get the results they expected was the modular structure of the qualification.

''While all the exam boards increased grade boundaries and had modular qualifications, attention has focused on AQA because most students take English with us.

''We care deeply about the students that sit our exams and are acutely aware of the distress caused to candidates who were disappointed by their GCSE English results last summer. Clearly there are lessons to be learned all round from what happened, and we will work very hard with teachers, the regulator and the other exam boards to improve understanding and prevent something like this happening again.''

A Department for Education spokesman said: ''The judgement demonstrates that overall Ofqual got it right last year. Attention can now focus on reforming GCSEs ready for first teaching in 2015.'