A child sex killer who is seeking his freedom after being detained in Carstairs State Hospital for 23 years was assaulted in court yesterday.

Michael Wilkinson sexually assaulted and strangled a six-year old girl in Dundee in 1974.

Wilkinson, now 50, was at the Court of Session where he is asking Lord Marnoch to overturn a sheriff's refusal to allow him his freedom.

As he was being led from the court at lunchtime under escort by three members of Carstairs staff, a young man, who had been sitting at the back of the court listening to the legal debate, approached.

He called Wilkinson a bastard and punched him hard on the jaw. Wilkinson's head was banged off the wall and he slumped to the ground. Two of the Carstairs staff pinned the attacker face down on one of the public benches. The man, tall and casually dressed, was later led away by police.

Wilkinson was examined by a police surgeon and was able to come back to court after lunch, when there was a police presence in court.

Wilkinson's case follows that of psychopathic killer Alexander Reid in August this year in which three Court of Session judges ruled that Reid could no longer be detained at the State Hospital after 30 years because his condition was not treatable.

He is being kept inside while Scottish Secretary Donald Dewar appeals the decision to the House of Lords.

Wilkinson's case raises a different point - that although he is a paedophile, he cannot be regarded as suffering from a mental disorder and cannot therefore be detained at Carstairs.

The case is again being opposed by the Secretary of State, who is arguing that Wilkinson should not be released since he suffers from a mental disorder as well as being a paedophile.

Wilkinson was sent to Carstairs without limit of time in 1974 after being convicted of the culpable homicide of six-year-old Pauline McIvor, a friend of his

daughter. After he sexually assaulted her and strangled her with a skipping rope, her body was found dumped at the rear of a tenement.

Last night the wife of the alleged attacker said: ''I've heard my husband has been charged after jumping over the dock and assaulting Mr Wilkinson.

A sheriff has the power to order Wilkinson's release if he is no longer suffering from a mental disorder of a kind which makes it appropriate for him to be detained in a hospital for medical treatment.

After two unsuccessful challenges to his continued detention, Wilkinson tried again but, in April this year, Sheriff Frank Keane at Lanark rejected his case.

In his appeal to the Court of Session, Wilkinson is basing his argument on a section of the Mental Health (Scotland) Act which states that no person shall be treated as suffering from mental disorder by reason only of sexual deviancy.

Sheriff Keane heard evidence from five psychiatrists - three of whom said Wilkinson was suffering from a mental disorder and two that he was not.

One doctor took the view that sexual deviancy was only part of Wilkinson's personality disorder and that he was not a ''straightforward paedophile''.

She diagnosed him as suffering from ''mental disorder characterised by anti-social personality disorder manifested by egocentricity, lack of feeling for others, and lack of remorse for past offences''.

A second doctor considered Wilkinson to be suffering from ''primarily a personality disorder with features of paedophilia''.

In a report prepared in November 1995, the doctor stated: ''There remains an unacceptable risk that he will offend again against children.''

Sheriff Keane preferred the evidence of the majority of doctors and found that Wilkinson was suffering from mental disorder warranting his detention in Carstairs. In his case at the Court of Session, Wilkinson argues that there was no evidence before the sheriff that he had shown any abnormally aggressive or seriously irresponsible behaviour as a manifestation of a personality disorder within the meaning of the 1984 Act.

All the evidence before the sheriff was of treatment for paedophilia and no reasonable sheriff could have held that Wilkinson was receiving treatment for a mental disorder within the meaning of the Mental Health Act, nor that such treatment was likely to help or prevent anything other than paedophilia.

In the absence of such a finding, Wilkinson was entitled to be discharged from Carstairs.

The hearing continues.