In Dante’s time, books were sold in apothecary shops: literature as medicine. I learned this when I was very ill, during an acute episode of manic depression, and I was struck by the profound metaphor behind this commercial fact. The apothecary of literature can heal, and I would need it desperately.

I had experienced a psyche-fracture, which included hallucinations of wings, seeing my own and others’, these wings a metaphor for thought, the wings of the mind. Although I felt compelled to enact the urges of mania, I had a greater wish to hold very still and see what would happen if I let this madness take a metaphoric route. What happened? Poetry.

I don’t normally write poetry, but in this illness I could write nothing except poetry. I never normally write at night, but I could write only in darkness.

The ancient Greeks thought the gods inspired poets through madness, and in Ion, Plato has Socrates say: “For the poet is a light and winged and holy thing, and there is no invention in him until he has been inspired and is out of his senses.” This furor poeticus was honoured in the Renaissance as the “fine madness” that “should possess a poet’s brain”, in the words of the Elizabethan poet Michael Drayton.

In the illness I could write nothing except poetry

For me, poetry is medicine. The poet Les Murray writes: “I’d disapproved of using poetry as personal therapy, but the Black Dog taught me better. Get sick enough, and you’ll use any remedy you’ve got.” In the 19th century, people in asylums were encouraged to write poetry, while William Cowper (1731-1800) wrote that, in his depressions, “I find writing, especially poetry, my best remedy.” Orpheus was both healer and poet and his lyre could vanquish melancholy.

I was also taking psychiatric medication, but in medicine I saw the science of pain, whereas in poetry I saw pain’s art. Medicine has an anaesthetic relationship to pain – it wants to rid the patient of it. Poetry’s relationship is aesthetic – it wants pain to speak. And the condition that seems to speak more than any other is manic depression. Arguably, it may be the refusal to create one’s art that causes distress in the first place. John Keats, a licensed apothecary, as was Dante, trained unhappily as a doctor and experienced depression accordingly: his brother feared that if John didn’t become a poet he would kill himself. An unanswered calling can take its revenge, and Gwyneth Lewis’s memoir of depression, Sunbathing in the Rain, notes that it was her resistance to writing poetry that made her ill: “If you don’t do what your poetry wants you to, it will be out to get you. Unwritten poems are a force to be feared.”

The first book I could read in “recovery” was Richard Holmes’s biography of Coleridge, and I cried for the poet, born before the modern apothecary of psychiatric medication that could have saved him so much pain. Coleridge, describing Shakespeare’s Mercutio, also describes himself, or indeed many a mercurial writer: “possessing all the elements of a poet: high fancy; rapid thoughts; the whole world was as it were subject to his law of association”. Mercutio is moody then soaring; his mind is in flight with the imagery of wings.

In Shakespeare I feel understood, for he catches the signatures of manic depression in many of his characters, from Cleopatra to Timon, Lear to Antonio in The Merchant of Venice. Touchstone, merry-mad in motley, suggests mania, while Jaques, melancholy in his black, stands for depression. The most deft description of mania I have ever read – “frantic-mad with evermore unrest” – is Shakespeare’s, while his love for puns and word creation, his tender empathy, his connotative mind, word association and lapidary compression all suggest to me that he either experienced it or understood it intimately in another. If not Shakespeare himself, my money is on the actor Robert Armin, Shakespeare’s clever clown, the probable author of A Pill to Purge Melancholy.

To heal is, etymologically, to make whole, and poetry can heal the connective tissues of the mind, making it whole and reuniting it with the world. In the awful loneliness of depression, poetry is the kindest companion when one is keening to be comprehended. The contemporary practice of bibliotherapy makes this explicit, asking people to read specific texts as medicine, and in Black Rainbow, Rachel Kelly explores the curative power of poetry for her savage depression. Sufi stories have long been used as remedies and in Australia I met an indigenous “story‑doctor” who would diagnose someone’s psychological state and prescribe a particular story for them to cure their situation.

Coming home, I bought all three anthologies Staying Alive, Being Alive and Being Human, so I could read a poem chosen by Neil Astley every day. Astley saves lives, I thought, many times. The subtitle of Staying Alive is “real poems for unreal times”: crisis, grief, love and, yes, madness, that state of unreality or – as I prefer – irreality.

For me, writing poetry at night was an enactment of a metaphoric truth: I could see better in the dark.

• In the UK, the Samaritans can be contacted on 116 123. In the US, the National Suicide Prevention Hotline is 1-800-273-8255. In Australia, the crisis support service Lifeline is on 13 11 14. Hotlines in other countries can be found here.