IT IS a story of spying, sex and Freemasonry – of shipwrecks, double crossing secret agents, seduction, treachery and the making of the myths that form the basis of the Da Vinci code.

But this is not the plot of the next blockbuster film, but the real life story of our national poet Robert Burns’ forgotten relative.

Previously undiscovered details of the story of Captain Sir Alexander Burnes, whose father was the Bard's first cousin, are to be brought to life in a new book by Craig Murray, the former British ambassador to Uzbekistan.

Murray claims he consulted "thousands of manuscripts" while researching Sikunder Burnes, Master of the Great Game – due to be published by Birlinn next month – to uncover the truth about the man nicknamed Bokhara Burnes. This is a reference to his exploration of Bukhara, a trading centre in the country where Murray was a diplomat before being dismissed in 2004.

The then 26-year-old Alexander Burnes was one of the first agents to be sent to Afghanistan by British Intelligence in 1831 as power politics heated up between Britain, who wanted to hold on to India as the jewel of its empire, and Russia. He travelled the route from Kabul to Burkhara in disguise.

In accounts of the 1,000 mile journey Burnes made up the Indus river Murray found previously unpublished details of double-crossing deals, secret mapping techniques, false letters and disguises.

He also claims to have discovered evidence of the British secret service smuggling arms to Chechen and Dagestani rebels as early as the 1830s, aiming to use the Mujahideen to wage 'jihad' against Russia. The move, he notes, has striking parallels with modern-day warfare.

And although he didn't set out to research Burnes' Freemason links, Murray also discovered documents that suggest it was Alexander, along with his brother James, who first invented the myths that link the Knight's Templar to Scottish Freemasonry, inspiring bestsellers from Dan Brown's Da Vinci Code to Foucault's Pendulum by Umberto Eco.

Murray said: "When I stared writing about Alexander Burnes it was because he had been a diplomat in the same part of the world as me. But it quickly took me to all sorts of discoveries about the myths of the Knights Templar and Scottish Freemasons.

"It turns out that was first published by Alexander's brother James in1837, in Sketch of the History of the Knights Templar. I've tried very hard to find any earlier mention and it is not there. So it seems like James and Alexander invented it."

On the strength of stories of secret symbols in Afghanistan and Freemasonry documents in the Church of Saint-Sulpice in Paris, Murray claims James Burnes rose rapidly through Freemasonry ranks. Alexander was killed in Kabul in 1841.

Other fascinating finds included hugely details accounts of spy techniques.

"Burnes would be disguised as a traveller but counted his paces as he went in order to map,” he said. “The maps were drawn secretly at night in his tent. They would then be crushed down in amulets to be smuggled out and sent back by messengers who were themselves travelling in disguise. It's fascinating detail.

“There was lots of double dealing – intercepting letters from the Russians, the use of complex codes to foil the other side.

“His sex life was also interesting. All of the histories repeat claims that it was his active sex life with Afghan women which motivated the Afghan uprising...But I couldn't find any evidence that's true at all. What I did find was very definite evidence that he took a harem of women who he had been travelling with for three or four years.”

Robert Burns, would have been proud of his ancestor, he added:"His warm humanity, complete lack of racism, and Scottish enlightenment attitudes, including his contributions to geology, archaeology and palaeontology, showed Alexander’s intellectual range.”

Professor Gerrard Carruthers, director of the Robert Burns Centre at Glasgow University, agreed that there were parallels to be found between the two men. "Burns himself was famously a Freemason and at the time it was associated with being cosmopolitan in outlook, intellectual and adventurous.

"Of course this changed as you move through the 19th Century. But perhaps Alexander was imbibing something of the spirit of his uncle in his adventures."

Ian Gardner, director of Rosslyn Chapel Trust, which will be celebrating the 10th anniversary of the Da Vinci Code with screenings later this month, claimed the truth of the myths of the Knights Templar were hard to pin down.

"This may be right historically but the difficulty with all the myths and legends that are associated with Rosslyn is that it's very hard to prove them or dispute them,” he said.

"This is another dimension but it will most likely remain a mystery. That is part of what makes Rosslyn."

Campaigners are calling on the United States to reverse the decision to deny Murray, the former British ambassador of Uzbekistan, the right to enter the country without a visa.

Craig Murray was to present the Sam Adams Prize later this month – at an event coordinated by global peace movement World Beyond War – to ex-CIA whistleblower on waterboarding, John Kiriakou.

Murray won the prize in 2005 after speaking out on the UK’s alleged complicity in the Uzbek government's use of torture and extraordinary rendition. Other past winners include Julian Assange, Edward Snowden and Chelsea Manning.

A petition protesting the move, and set up by World Beyond War has attracted over 15,000 signatures, including Roger Waters of Pink Floyd.

The US State Department said it did not comment on visa decisions due to reasons of confidentiality.