(CNN) -- Nelson Mandela spent almost three decades in jail, but he wasn't alone -- he had two Indian goddesses and a 17th century playwright for company.

Locked in solitary confinement on Robben Island, newspapers were banned and letters from loved ones a rare treat.

Where did he find the inspiration to continue his long struggle for freedom?

As the twittersphere explodes with quotes from the legendary leader, it's perhaps easy to forget there was a time when Mandela was in need of a few words of wisdom himself.

He found them in the musings of another great thinker -- one born centuries before and on the other side of the world.

A tattered book covered in luminous Hindu deities might have seemed like a strange choice for the South African political activist languishing in his cell.

But the beatifically smiling women on the cover knew something the prison wardens didn't.

Inside was the "Complete Works of Shakespeare," and the historic text became a source of strength for Mandela and his fellow inmates during their darkest days.

A bible by any other name

It became known as the "Robben Island Bible," and today is one of the most remarkable artifacts from Mandela's 27 years in jail.

"What resonance does a white guy from England 400 years ago have to a group of South African political prisoners in the latter half of the 20th century?" said Matthew Hahn, who wrote a play based on the "Robben Island Bible," and interviewed many of the inmates who read it.

"There's this universality to Shakespeare -- including many lessons on good and bad leadership -- and I think Mandela found resonance in his words. He once said that 'To be taken seriously as a politician, one must always quote from Shakespeare,' and a lot of his speeches when he was president did just that."

Read: Nelson Mandela -- Fast Facts

The valiant

The book was smuggled into the jail by political prisoner Sonny Venkatrathnam, who disguised it in colorful Diwali cards celebrating the Hindu festival of lights, convincing the warden it was his bible.

Between 1975 and 1978, the volume was passed between 33 of Venkatrathnam's fellow prisoners -- including Mandela.

Many of the inmates signed and dated their names beside particularly poignant passages -- words of hardship, political unrest, or injustice.

Mandela chose a passage from Julius Caesar -- just before the Roman statesman leaves for the senate on the Ides of March -- and his sweeping handwriting on the now-yellowing page is a haunting reminder of the activist's dedication to his cause.

It includes the lines: "Cowards die many times before their deaths/The valiant never taste of death but once."

Read: Nelson Mandela -- Examining the backlash

"I believe when Nelson Mandela signed this passage, he recognized this book would get out and be circulated in the liberation movement -- his would be the quote people looked to," said Hahn.

"It was an incredibly powerful quote -- he lived his entire life according to these two lines."

Lasting impression

The quote is all the more poignant considering Mandela's speech during the 1960s Rivonia Trial, where he said: "If need be, it is an ideal for which I am prepared to die."

Mandela signed the passage December 16, 1977. He never could have imagined that December 16 would later be known as "Reconciliation Day" in South Africa -- a public holiday which only came into effect after the fall of apartheid.

While Hahn believes the "Robben Island Bible" began as an attempt by Venkatrathnam to gain the autographs of the most famous political activists at the time, it has now become a powerful memento of their many years -- and sources of inspiration -- behind bars.

Read: Nelson Mandela -- Man of many handshakes

"It was amazing to see visitors from all over the world drawn to this book like a magnet," said Jonathan Bate, Professor of English Literature at Oxford University, who helped curate the British Museum's Shakespeare exhibition last year.

"It was a coming together of one of the greatest writers of humanity, and one of the greatest humans of the 20th century. With Mandela's death comes a particular poignancy in a passage referring to the death of the valiant."