The prisoners from Addiewell Prison in West Calder collected over £750 for 9-year-old Zoe Donaldson who was diagnosed last year.
The youngster, from Addiewell, was left blind following an operation to remove the medulloblastoma tumour and also went through intensive chemotherapy and radiotherapy.
But kind-hearted prisoners have chipped in to help buy a pony for Zoe which is trained to work with children with disabilities.
Audrey Park, director at HMP Addiewell, said: “Many of the prisoners were very eager to help Zoe when they heard about everything she had been through at such a young age.
“We encourage prisoners to help fundraise, particularly for the local community, as it plays an important part in the rehabilitation process.”
The idea to raise money came from prison cashiers Laura Johnston and Kerry Egan who heard about the youngster’s condition.
And Zoe’s parents, Bill and Vivienne Donaldson, have expressed their gratitude to the prisoners for the money they raised.
Mrs Donaldson said: “We would like to thank the prisoners at Addiewell for all their support and for raising such a generous amount of money.
“Zoe has been out on the pony already and this will assist in her rehabilitation by helping to build her strength.
“She has started back at school part-time, which she is enjoying and receiving great support from teachers.
“We are so grateful for the prisoners’ donation and the prison’s positive response to Zoe’s illness.”