Spanish writer Miguel de Cervantes, the author of Don Quixote, was imprisoned in Algiers for five years. As we near the 400th anniversary of his death, Fiona Macdonald finds out how trauma shaped his greatest works – from a scholar who was herself held hostage.

They knew him by his rib. “When I saw that rib – I thought, ‘We've found [him] at last!’,” forensic expert Francisco Exteberría told NPR. He had noticed the letters MC on a fragment of the coffin; the flayed rib and the crippled left arm picked up in the Battle of Lepanto.

It was 2015. Deep in the sub-soil of a 17th-Century convent’s grounds, operating quietly so as not to disturb the 12 cloistered nuns who live there in silence, the team of archaeologists and forensic anthropologists had uncovered the remains of at least 15 people – before they came across the splintered coffin.

“The whole team was there in silence, underground, studying what we found – and we all knew.” Even before he received the results from the DNA analysis, Exteberría was sure. In the crypt beneath Madrid’s Convent of the Barefoot Trinitarians lay the skeleton of the great Spanish writer, Miguel de Cervantes.

In 1575, after fighting in military campaigns against the Turks in the Mediterranean, the Spaniard was captured by Barbary pirates and taken to Algiers. There, he was kept as a slave for five years. When he was freed – with a ransom raised by Trinitarian friars attached to the convent he was to be buried beneath – he had become the man who would write one of the greatest novels in history.

“His five-year captivity in Algiers left an indelible impression on his fiction,” Cervantes scholar María Antonia Garcés tells BBC Culture. “From the first works written after his liberation, such as the play Life in Algiers (c. 1581-1583) and his novel La Galatea (1585), to his posthumous book The Trials of Persiles and Sigismunda (1617), the story of this traumatic experience continuously speaks through his work.”

Life-saving literature

Garcés, who is professor of Hispanic studies at Cornell University, understands the trauma of captivity. Between December 1982 and July 1983, she was held hostage by a guerrilla group in Colombia. “I have always read intensely and found solace in literature,” she says. “I survived my captivity, I think, thanks to some of the books my captors brought me, which I requested, including a decrepit Spanish translation of Oscar Wilde’s Complete Works… When I had nothing to read, I read a Larousse Spanish Dictionary from top to bottom. The marvel of words has always fascinated me.”

I survived my captivity, I think, thanks to the books my captors brought me. My love of literature kept me alive – María Antonia Garcés

She also read Cervantes, whom she credits with helping her survive in the following years. After her release, Garcés began to study his work. “I became a scholar after getting a new lease of life, after being liberated,” she says. “I was a survivor, after seven months of captivity, where I was locked in a tiny, windowless cell, constantly guarded by armed jailers and often threatened with death by my kidnappers. My love of literature kept me alive, and I wanted to make the most of what remained of my life… I have done this by becoming a scholar and working on Cervantes.”

Garcés’s 2005 book Cervantes in Algiers: A Captive’s Tale explores the idea that survivors of traumatic events have an urge to repeat their stories. She describes how Cervantes told and retold his own account of enslavement: in plays, poetry and novellas including The English Spanish Girl and The Liberal Lover, as well as what Garcés calls “Cervantes’s most important autobiographical narrative” – the tale told by a captive in Part 1 of Don Quixote.

Repeat to survive

This need for repetition tallies with the experiences of other traumatised individuals. In Bearing Witness or the Vicissitudes of Listening, which is based on interviews with Holocaust survivors, Yale psychiatry professor Dori Laub states that the subject of trauma “lives in its grip and unwittingly undergoes its ceaseless repetitions and reenactments.” Trauma survivors, argues Laub, “live not with memories of the past, but with an event that could not and did not proceed through to its completion, has no ending, attained no closure, and therefore, as far as its survivors are concerned, continues into the present and is current in every respect.”

The retelling is not just a compulsion; it might also help trauma survivors to heal. In an interview, the writer Primo Levi, who survived the concentration camp at Auschwitz, said: “I told my story to everyone and anyone, at the drop of a hat, from the plant manager to the yard-man... just like the Ancient Mariner”.  According to Garcés, “Telling the story time and time again may have therapeutic effects; each time you repeat, you change something, as Freud noted. In the case of Cervantes, I think this led to introspection and to an interest in the workings of madness. Two of his great works deal with madmen: Don Quixote and The Glass Graduate.”

It could be this interest which marks out Don Quixote as the first truly modern European novel. “I would argue that Cervantes’s explicit interest in the question of madness emerges from the borderline situations he endured as a captive, from the encounter with death that transformed him into a survivor,” writes Garcés in Cervantes in Algiers. His reflection on madness “converts him into a pioneer in the exploration of the psyche three centuries before Freud.”

Trauma is a wound in the psyche that has not been processed – María Antonia Garcés

Garcés points out that the writer’s focus on captivity extends to what she calls “figurative incarcerations” such as the delirium that imprisons Don Quixote, or the madness that captures the deranged scholar Vidriera. Cervantes returned again and again to his time as a slave through his characters. “Trauma is a wound in the psyche that has not been processed,” says Garcés. “Cervantes’s works seem haunted by the re-enactments of trauma, possessed by the continual images and dreams that assault the survivor.”

Yet for Cervantes, telling the story of his trauma went beyond testimony. Spanish cultural historian Américo Castro described the author’s captivity as “the most transcendental event in his spiritual career”; for critic Juan Bautista Avalle-Arce, it is “the hinge which forcefully organises the entire life of Cervantes”. According to Spanish poet and novelist Juan Goytisolo, it was “that void – hole, vortex, whirlwind – in the central nucleus of the great literary invention”. The five years in Algiers, says Goytisolo, was a life-changing experience: “Cervantes elaborated his complex and admirable vision of Spain during his imprisonment in African territories, in opposition to the rival model against which he clashed.”

Arguably, the writer’s enslavement not only broadened his vision – it broadened the scope of the novel in general. For Garcés, Don Quixote signals “the birth of a new era through its incorporation of marginal and culturally ambiguous groups”. They include the Moriscos (former Muslims who converted or were coerced into converting to Christianity), pícaros (rogues who live by their wits), and renegades “that people its literary universe”. This was a direct result of his enslavement. “His experience as a captive in the bagnios [slave-houses] of Algiers, his personal relations with Muslims and renegades, his encounter with different cultures and religions in this multicultural city that welcomed corsairs from every part of the world offered him the possibility of examining these issues from a unique perspective.”

Fantasy figure

Garcés believes that Cervantes’ traumatic experience “opened the door of creation for him”. And in turn, the trauma Cervantes retold through his novels, plays and poetry helped Garcés through the most difficult time of her life. She wrote Cervantes in Algiers in the period following the death of her eldest son.

Cervantes has been the great teacher, the healer who has helped me to reattach the broken thread of my life – María Antonia Garcés

“The most important resource in this process of grieving and recovery… has been my writing on Cervantes,” she writes in the preface to Cervantes in Algiers. “More than anyone or anything else, Cervantes has been the great teacher, the healer who has helped me to reattach ‘el roto hilo de mi historia’ [the broken thread of my life] as I read, and wrote about, his fictions.

“The remarkable fertility of his creations that swirl around the vortex of trauma has shown me that it is possible to turn trauma into song… Revealing a truth impossible to assimilate, these are the stories of a wound that cries out, that addresses us in an attempt to express an indescribable reality.”

Viewed in this way, telling a story can truly save a life. In the words of Coleridge’s ancient mariner: “Since then, at an uncertain hour/That agony returns;/And till my ghastly tale is told/This heart within me burns.”

If you would like to comment on this story or anything else you have seen on BBC Culture, head over to our Facebook page or message us on Twitter.

And if you liked this story, sign up for the weekly features newsletter, called “If You Only Read 6 Things This Week”. A handpicked selection of stories from BBC Future, Earth, Culture, Capital, Travel and Autos, delivered to your inbox every Friday.