It includes lyrics like: "You put me through hell / I had to learn how to fight for myself," and, "You said I was done / But you were wrong / And now the best is yet to come."
She also sings: "When I'm finished they won't even know your name."
Many fans said the song, a piano-led power ballad, moved them to tears.
She said of her track: "Praying, my first single in almost four years, comes out today. I have channeled my feelings of severe hopelessness and depression, I've overcome obstacles, and I have found strength in myself even when it felt out of reach. I've found what I had thought was an unobtainable place of peace.
"This song is about coming to feel empathy for someone else even if they hurt you or scare you. It's a song about learning to be proud of the person you are even during low moments when you feel alone. It's also about hoping everyone, even someone who hurt you, can heal."
And Kesha - who hasn't released solo material since the court battle began in 2013, but did appear in a 2016 collaborative song with Zedd entitled True Colours - hopes her single will resonate with people who are "in the midst of struggles", as she urged them to never "give up".
She continued: "It's from our darkest moments that we gain the most strength. There were so many days, months even, when I didn't want to get out of bed. I spent all day wanting to go to sleep, and then when I did fall asleep, I had horrible night terrors where I would physically cry and scream through the dark. I was never at peace, night or day.
"But I dragged myself out of bed and took my emotions to the studio and made art out of them. And I have never been happier with a body of work as I am with this record."I hope this song reaches people who are in the midst of struggles, to let them know that no matter how bad it seems now, you can get through it. If you have love and truth on your side, you will never be defeated. Don't give up on yourself."
The blonde beauty has also revealed she will be releasing her third studio album Rainbow - her first since 2012 - in August.
Writing in an essay for Lena Dunham's Lenny Letter, Kesha said: "This is just the beginning. I am so happy and grateful to begin sharing all the music I have been writing with the world. I've written a record that reveals my vulnerabilities, and I have found strength in that.
"In the past, I've always felt like I was trying to prove something, trying to be someone I thought people wanted me to be, but on this record, I'm just telling the truth about my life. This album is me. The most raw and real art I have ever created, and now it's my gift to you. I hope you love it. Thank you for not giving up on me. We made it. I love you all so much."
Dr Luke, whose real name is Lukasz Gottwald, has denied Kesha's allegations.
Rainbow is due out August 11 and features appearances by Dolly Parton, Eagles of Death Metal and the Dap-Kings.