John Hardie, backed by the Educational Institute of Scotland, had sought a judicial review of the decision. The judgment by Lord Osborne immediately led to a war of words between the council and the union which said it illustrated the dangers of giving directors of education the powers they want to sack teachers.
Ronnie Smith, the EIS's general secretary, said: "This decision breaks new ground in providing additional protection for vulnerable staff engaged on insecure temporary and casual contracts and fully vindicates the decision of the EIS to take this matter to court."
Colin Dalrymple, head of education support services in Edinburgh, said he was "flabbergasted" by the EIS's attitude. "Our first priority has to be the care and welfare of children in our schools," Mr Dalrymple said.
Lord Osborne based his ruling on procedural flaws in the way Mr Hardie's case was handled. Mr Dalrymple acknowledged that but said "grave concerns" remained, although the authority now has no option but to restore his name to the supply list.
Mr Hardie, aged 57, was accused of taking a pupil on to his knee during a lesson at Murrayburn primary in Edinburgh in March. The pupil complained and, following an interview with Tom McMillan, the education department's employment manager, Mr Hardie was told that "on the balance of probabilities" professional misconduct took place.
Mr Hardie protested that the pupil was not at any time on his knee but "propped up against it".
Mr McMillan said, however, that he had received information from the school that the incident took place in front of the class. Mr Hardie had been "initially evasive" during the interview but later confirmed the pupil was on his knee.
Lord Osborne concluded that there had been a breach of natural justice because Mr Hardie was kept in the dark about the nature of the allegations before his interview with Mr McMillan and was given no time to prepare a defence.
He also criticised Edinburgh's failure to allow him sight of a report from Jeanette Perry, the school's head, who had provided the "independent corroboration".
Mr Hardie, who has breathing problems, became unwell at the end of the interview and was unable to drive home straight away. Although his name was removed from Edinburgh's list, he has been taken on to East Lothian's books.
The EIS immediately claimed "a significant victory" and accused Edinburgh of behaving in "a cavalier and high-handed manner".
Mr Dalrymple said the authority was unable to follow its normal disciplinary procedures because Mr Hardie, while available for teaching, was not actually employed by the council when the decision was taken to remove him from the supply list.
"Perhaps the EIS would join with us in a constructive dialogue to investigate how any local authority can ensure there is natural justice for children when it is blocked from pursuing a case because of the nature of temporary contracts," he said.
The authority would not let the case rest and was seeking legal advice. It had not yet passed details of the case to the General Teaching Council while court proceedings were pending because that might have been regarded as prejudicial.
Mr Smith observed that the council's "feckless conduct" should temper the enthusiasm of those who want to give directors of education greater powers to dismiss teachers more easily.