The Scottish government has paid out more than £8.5m in compensation to overcrowded prisons since 2007, according to figures released by the Scottish Liberal Democrats.
The payments were made to compensate prisons for costs associated with keeping more prisoners than they were resourced to hold.
The Lib Dems obtained the figures by tabling a parliamentary question.
The Scottish government said it was addressing Scotland's reoffending rate.
The figures indicate more than £4m was paid out to Barlinnie Prison between 2007 and 2010, while Kilmarnock received nearly £2.5m.
Scotland's only women's prison, Cornton Vale in Stirling, was given £241,000.
Liberal Democrat justice spokesperson Robert Brown said: "Our figures show a new cost to overcrowding.
"That £8.5m should be going into investing in tough and effective community sentences rather than a sticking plaster to keep overcrowded prisons going.
"Overcrowding puts at risk the good work that prisons do on rehabilitation, cutting reoffending and tackling the root causes of crime."
A Scottish government spokesman said law-breakers were being punished swiftly by Scotland's justice system, with criminals being given the longest prison sentences in a decade.
He continued: "But at the other end of the scale, we need to address Scotland's appalling reoffending rate for low-level offenders.
"These offenders are going in and out of prison, time and time again, and committing more crime in communities upon release.
"The facts speak for themselves, with three-quarters of those sentenced to a short prison sentence of three months or less going on to reoffend within two years of getting out - but in direct comparison three out of five given a tough community sentence do not."
He added: "That is why earlier this month we announced an additional £4m funding to be allocated to Community Justice Authorities across Scotland to help deliver community payback, and to improve its speed and effectiveness on the ground."
Last month, the Scottish Prison Service (SPS) was told it could not build a new prison on land earmarked for a new academic and research campus in Inverness.
The SPS had been in discussion with landowner Highlands and Islands Enterprise (HIE) about constructing HMP Highland at Beechwood.
HIE said the plan was given serious consideration but it did not have "a strong strategic fit" with its vision.
It offered to help the SPS find another site.