The charity introduced its listening service at HMP Edinburgh in 1994 to cut the rate of suicides and self-harm. It now operates in each of the country's 16 prisons.
Under the scheme, Samaritans workers train inmates to listen in confidence to fellow prisoners who need to talk.
Last year there were almost 750 meetings between the volunteers and prisoners in need.
Orla McCaffrey, from the organisation, said: "Being in prison can have a profound effect on an individual's state of mind.
"Twenty years of supporting vulnerable prisoners across Scotland is an important milestone for both Samaritans and the Scottish Prison Service.
"We are very grateful to the management and staff teams in the prisons for the help they provide."