A former prisoner is suing the Scottish Government for £900,000 damages after claiming the prison system failed to protect him from a violent racist who smashed his skull with a barbell.

Daniel Kaizer was the victim of a murder bid by fellow inmate Keith Porter, who attacked him in Craiginches prison in Aberdeen and was later given a life sentence for the racially aggravated offence.

Porter had admitted the attempted murder of another Polish national, Jaroslaw Janecek, in a horrific assault with a mop handle days before the gym attack on Mr Kaizer.

On Tuesday at the Court of Session in Edinburgh, a hearing on liability began after Mr Kaizer raised an action suing the Scottish Government for £900,000 following the assault.

He told the court in an earlier incident Porter had been "really verbal to me" and was swearing at him about a week before the attack in the jail gym.

Mr Kaizer, who was on remand at the time for assault, said he had gone to speak to one of the prison officers.

He said the officer had gone to another Polish prisoner and asked him to look after Mr Kaizer and protect him.

The 34-year-old, from Aberdeenshire, said that on December 4, 2009, he was back in the gym with the other Polish inmate where Porter was with some of his associates.

He saw three men attack his compatriot and told the court: "Two guys were punching him on the face and the third guy was punching him on the side.

"That's the last thing that I remember before I got hit on the head."

He said he regained consciousness "with blood everywhere" and was taken to hospital for an operation to repair a depressed skull fracture.

In the damages action it is claimed the Scottish Prison Service knew Porter was a danger to other inmates and claims he was notorious in the Aberdeen area.

Porter had more than 30 convictions, many for violence, and in 2005 was convicted of four charges with a racial element.

It is said: "Failure to institute and maintain and failure to adhere to a proper system of monitoring inmates creates the risk of violent racists, such as the said Keith Porter, being able to commit further similar offences upon other members of the prison population, as in fact happened in this case."

The SPS allegedly failed to adequately assess the supervision level required for Porter.

It is alleged they failed to classify Porter, 28, as a high risk prisoner.

In the action it is said: "Had the system worked, the threat posed by Porter would have been identified, he would have been classified correctly as a high risk prisoner, would have been properly supervised and the assault upon the pursuer would not have occurred."

The SPS ought to have been aware of the true level of threat posed by Porter to other prisoners in general and Polish inmates in particular, it is claimed.

It is also alleged a prison officer did not record the earlier gym incident or submit an intelligence report.

The Scottish Government said the prison officer had asked to identify the prisoner concerned in the initial gym incident but he refused to do so and did not advise that the episode had a racist element to it.

It maintains that before the murder bid, Porter had not been reported as having been involved in any racist incidents and had "no markers for violence or racism" on a prison system.

The government said there was insufficient information available to the service to justify segregating Porter.