He is a 28-year-old garbage collector in Bangkok, struggling to provide for his family.
While collecting garbage, he came across some music and movie CDs.
Mr Surat Maneenopparatsuda, 28, decided to sell them for 20 baht (80 Singapore cents) apiece, Bangkok daily The Nation reported.
But he was hauled up for copyright infringement and fined 133,400 baht (S$5,300).
Unable to pay the fine, he was sent to jail on Thursday.
He would have had to spend at least 665 days in prison as one day in prison is for 200 baht in fines.
But a good Samaritan stepped up and paid the fine, and Mr Surat was released on Friday.
Mr Surat has attracted a lot of public sympathy, partly because he committed the crime out of ignorance. He had argued that he was unaware that his actions were illegal.
Mr Woranai Bamnejphan, a lawyer for the good Samaritan, said he could not disclose any details as the donor wanted to be remain anonymous.
District officials said Mr Surat was a hard-working garbage collector and was loved by his colleagues. He has an 11-year-old daughter who is ill.
Mr Surat's father, Mr Surasit Maneenopparatsuda, also a garbage collector, said Mr Surat was the sole breadwinner and that he was very grateful for the donation, Bangkok Post reported.
Mr Surat's daughter, Jantima, and Mr Surasit rushed to the court as soon as they heard that the fine had been paid.
"We are grateful for the many people who wish to help our family," Mr Surasit said.
Mr Surat added: "I will go back to work to support my parents and my daughter." He said he has learnt an expensive lesson - he didn't know selling those CDs was against the law. It was the first time he had sold them.
This article was first published on November 16, 2014.
Get The New Paper for more stories.