Dokic, who played her last professional match in 2014 and has worked as a commentator on Australian TV in recent years, said she had been battling “constant feelings of sadness and pain”.
“Such a vicious cycle in my head. The result: almost jumping off my 26th floor balcony on April 28th,” the 39-year-old wrote in a post.
“I just wanted the pain and the suffering to stop. I pulled myself of the edge, don’t even know how I managed to do it.”
Dokic has been open about her mental health battles and said in her 2017 book “Unbreakable” that she had suffered years of physical and emotional abuse from her father.
Born in the former Yugoslavia, Dokic said on Instagram that the last six months had been tough but seeking professional help had saved her life.
“From hiding in the bathroom when at work, to wipe away my tears so that nobody sees it, to the unstoppable crying at home within my four walls has been unbearable,” said the former world number four, who won six singles titles on the WTA Tour.
“I am writing this because I know I am not the only one struggling. Just know that you are not alone.”
Dokic said some days were better than others but she was on the road to recovery and vowed to return “stronger than ever”.
Her post triggered supportive messages from a number of Australian sporting figures.
“You are enough. You are worthy. Your pain will heal,” former Olympic champion cyclist Anna Meares said. “You will find peace. Hang in there.”
Mental health has been in the spotlight in tennis since former world number one Naomi Osaka withdrew from last year’s French Open and said she was battling depression.
Men’s world number two Alex Zverev opened up about his own mental health issues during the recent French Open, saying social media meant current players were subject to “a lot more hatred” than past ones.