After centuries of dwelling in history’s shadows – being blamed for everything from assassinating JFK and establishing a New World Order to the Jack the Ripper murders and controlling the police force – the organisation waited anxiously for Dan Brown’s new book, The Lost Symbol, to appear in bookstores at the stroke of 12, dragging the secret society into the glare of a 21st-century media feeding frenzy.

Brown’s most famous literary offering, The Da Vinci Code, threw harsh light on another secretive society – the Catholic Church’s Opus Dei – causing serious PR problems for the organisation in real life. Would Brown’s creation, symbologist Robert Langdon’s latest adventure, follow suit, portraying the Masons as history’s conspiratorial bogeymen?

But a most unexpected thing happened: despite his trademark tortured prose, inexplicable use of italics, starchy exposition and plot twists borrowed from a Latin American soap opera, Brown may have pulled off something of a PR coup for the Masons.

Now instead of preparing a defence of what they call “their gentle Craft”, they could well be stockpiling application forms as readers see the society in a kinder, gentler light, because in The Lost Symbol, the Masons are – wait for it – the good guys.

By contrast, The Da Vinci Code portrayed Opus Dei as shadowy religious fanatics charged with lethally suppressing the secret of Jesus and Mary Magdalene’s relationship. Despite being fiction, it had a very real effect on the organisation.

“The book turned a private existence for our members into a more public one,” said Andrew Soane, Opus Dei spokesman. “The Da Vinci Code meant that members had the occasion to speak about their membership and had to explain themselves to a lot of people.”

The week The Da Vinci Code was released in 2006, enquiries increased tenfold. Membership numbers have remained steady, despite the negative depiction in a book that sold 80 million copies. With The Lost Symbol expected to do similar business, “the Masons should be prepared for increased interest”, warned Soane.

In advance of the novel’s release, senior Masons in the US voiced concern that “we might have to spend the next 25 years responding to Dan Brown’s fiction”. A website was set up in advance to combat untruths. The tension was palpable.

Author Brad Meltzer, whose Book Of Fate, another Washington-based Masonic thriller, topped the New York Times best-seller list in 2006, explained why they were nervous.

“For better or worse, people read these novels and take truth from them,” he said. “We don’t get educated by newspapers any more. We get educated by comedians, pop culture and fiction. And we are talking about the biggest book of the year. The Masons are stars of it. Their symbol is on the front cover. Six million people are going to read it. Only a fool wouldn’t be nervous.”

On Wednesday afternoon, however, the only thing jangling within the marble halls of the Grand Lodge of Scotland was the sound of a teaspoon against porcelain. The receptionist was making a cup of tea for the Grand Secretary, David Begg.

Brown’s Masonic revelation had been published the day before. Hardback copies were flying out the door of nearby Waterstone’s. But sitting in his large office within the lodge on Edinburgh’s George Street, the centre of the Scottish craft, Begg was a man at ease.

“We haven’t geared up for this at all,” he said. “It doesn’t surprise me that Dan Brown wanted to write about the Masons. I’ll be interested to read it to make sure it isn’t too inaccurate.”

Begg’s calm may have to do with Brown’s benign view of his organisation. The plot, such as it is, involves Langdon attempting to rescue his kidnapped friend and senior Mason, Peter Solomon. His quest involves cracking Masonic codes set into the architecture of Washington DC, all the while evading the attentions of the CIA and a tattooed, castrated madman who believes the Masons hold the secret to becoming a god, the titular lost symbol. While in The Da Vinci Code Langdon raced to uncover Opus Dei’s secret, in The Lost Symbol he fights to protect the Masons. With a print run of six million, it has already become the biggest-selling adult hardback of all time.

Near the beginning Langdon says: “The entire Masonic philosophy is built on honesty and integrity. Masons are among the most trustworthy men you could ever hope to meet.” By the end of the novel, after being shot at, almost drowned and chased from monument to monument, his view is the same. They are “one of the most unfairly maligned and misunderstood organisations in the world”.

Brown’s view is not too far removed from his hero’s. “I have enormous respect for the Masons,” he said in a interview. “In the most fundamental terms, with different cultures killing each other over whose version of God is correct, here is a worldwide organisation that essentially says, ‘We don’t care what you call God, or what you think about God, only that you believe in a god and let’s all stand together as brothers and look in the same direction’.”

Begg is unsurprised by Brown’s generous treatment. “It wouldn’t surprise me that it is positive,” he said. “I’ve found a lot of misguided comments about freemasonry. I don’t find that overseas when I go there. I’d have to say it is more in Scotland and the UK that there is an inbuilt prejudice. But that is receding.”

The Freemasons possess a murky, misty history. Some trace their roots back to the builders of Solomon’s Temple, others claim Adam as the first Mason. But their modern origins are linked to the medieval stonemasons’ guilds who constructed cathedrals across Scotland and England.

The first recorded Freemasons as we know them, a brotherhood for all men not exclusively stonemasons, met at a lodge at Kilwinning in Ayrshire in 1599. The Grand Lodge of Scotland was formed in 1736 to unite the hundreds of lodges around the country. The first grand mason was William St Clair, whose family built the mysterious Roslyn Chapel. His portrait hangs in the grand lodge’s boardroom. The order’s creed of brotherly love, relief and truth still exists today, as well as some other medieval hang-ups: women are still barred from joining.

The Masons might not be subject to the negativity that plagued Opus Dei after its time in the Dan Brown spotlight, but The Lost Symbol still panders to another stereotype that dogs the organisation. Langdon’s ultimate discovery is that the Masons guard ancient secrets that can allow man to achieve god-like powers.

“The craft of Freemasonry has given me a deep respect for that which transcends human understanding,” says a senior Mason at one point. This could attract a new breed of excitable members, bewitched by the order’s alleged mysticism.

“It is a way of life, a philosophy. An approach to your fellow man and how to treat them,” said Begg. “But if they join in the anticipation that some cosmic secret will be revealed to them, they will be sorely disappointed.”

The codes and symbols that propel the novel appear to have a lot more substance than the book’s Masonic mysticism. Pyramids, double-headed phoenixes, all-seeing eyes, compasses and set squares lead Langdon deeper into his adventure.

The same imagery is dotted throughout the Grand Lodge of Scotland. A pyramid clock sits atop the mantelpiece in Begg’s office, near Robert Burns’s masonic apron. In the Lodge’s museum a painting hangs on the wall: a crescent moon and a sun with an eye in the centre float above a young Mason. A set square and compass hang from the chandelier in the main staircase.

“Symbols are still hugely important,” said AJ Morgan, a Masonic historian. “The order is immediately recognisable because of its universal logo of a set square and compass. Symbolism plays a large part in the lodge.”

But Begg said: “There are lots of signs and symbols involved, and they have allegorical meanings. I wouldn’t say they are hiding any secrets as such. They are symbolic within some of our ceremonies, but not in hiding any great secrets of the universe.”

At one point in the novel Langdon discusses the circumpunct, a circle within a circle, one of the oldest signs in the world. “It has many meanings,” he writes. “One of the most esoteric being the rose.”

He links the flower to the Rosicrucians, a Masonic degree within the Scottish Rite which “contributed to Masonic mystical philosophy ... had an enigmatic history that greatly influenced science”. In the Grand Lodge, roses emboss the staircase and wallpaper of the Grand Mason’s office.

Other aspects of Freemasonry that the book plays upon, such as the use of knives in ceremonies and chambers of reflection (rooms containing various symbols), are not dismissed.

“It is all symbolic,” said Begg. “The chambers of reflection would be part of a side order. It’s not something we would have in the Grand Lodge.”

The novel turns to Scotland at various junctures. Peter Solomon is head of the Scottish Rite in America, whose headquarters, the House of the Temple, has symbolism that “rivalled that of Scotland’s Rosslyn Chapel”.

George Washington, the first US president, and several drafters of the Declaration of Independence and US Constitution were Masons.

Above the door of the Grand Lodge’s library, a painting hangs: Washington dressed in Masonic regalia laying the foundation stone for the US Capitol Building with a Masonic trowel.

Begg and his fellow Scottish Masons are very proud of their links around the world. Scottish lodges are in 43 countries including Zimbabwe, Lebanon and China.

The dark-wood-panelled museum in George Street houses artefacts from the international lodges. Daily tours are given to the public as part of Begg’s wish to “throw back the veil of secrecy”.

“Throughout history people have thought the order and its ceremonies were secretive,” he said. “But they are more private than secret.”

Now, prodded by Brown, the Masons may start to finally emerge from the shadows, symbols in hand.