Dozens of skeletons have been unearthed during construction work in the exercise yard at Perth Prison.
The remains of at least 24 men and women were discovered in coffins stacked six deep in burial trenches.
They are thought to date from the 19th Century, when the institution was used as an asylum.
Tests carried out by bone experts suggested they had died during an epidemic of typhus, which was known at the time as gaol fever.
The disease was spread by lice in overcrowded, unsanitary conditions.
The skeletons, which have now been reburied, were discovered last summer during a multi-million pound refurbishment of the prison and details of the find have just emerged.
Archaeologists said they were in a very poor condition because the coffins had collapsed and they had been buried in clay.
All the victims were adults, aged from 20 to about 65, with at least five women.
Experts said the fact that both sexes were present led them to believe the skeletons belonged to asylum inmates.
This was supported by evidence of medical conditions from the bones, according to David Henderson, a bone specialist with Headland Archaeology Ltd. He said: “Two of the males had the bone lesions indicating the final stages of syphilis, when the bacterium can also invade the central nervous system and produce severe psychological delusions.“A third individual had hydrocephalus, which could cause brain damage and learning difficulties before effective treatments were invented.”“The fact that all the bodies were buried at one time, stacked six deep in cheap coffins in trenches, rather than individual graves, also suggests that they died in an epidemic in the asylum.”
He added the most likely disease was typhus, which killed too quickly to leave any signs on the skeleton.
Evidence showed other victims had suffered from conditions such as gout, rickets and fractured ribs.
A woman died shortly after her right arm had been amputated above the elbow.
Other conditions detected were gout, rickets and fractured ribs.
Another woman had no front teeth, probably caused by a blow to the face.
Update 2nd June 2008: Perthshire Archaeology