"There’s nothing in the world more powerful than a good story.” So says Tyrion Lannister in the series finale of Game of Thrones. Controversy around the merits of the finale aside, he’s right. Ever since the very first story was told far, far back in the mists of time, stories and the imaginings they encourage have given people and places meaning.

Scotland is no stranger to story-seekers. Sir Walter Scott’s Romantic novels sent thousands of tourists to places like Loch Katrine and the rolling hills of the ­Borders. Monty Python and the Holy Grail still prompts visitors to Doune ­Castle to imitate coconut sounds and put on mock French accents. More ­recently, Outlander made such a profound ­impression that historic sites associated with the novels and television series ­experienced a huge rise in visitor numbers thanks to the ­“Outlander effect”.

In terms of depth and wonder, ­however, no modern series plays on Scotland’s ­story quite like Game of Thrones. After all, it was a visit to Hadrian’s Wall in 1981 that prompted George RR Martin to ­create his world of ice and fire. ­Standing at the edge of what the Romans called ­civilisation, he wondered what horrors – real and ­imagined – might come charging out from the rugged north.

A fun pub quiz could be based around the superficial resemblances between Westeros and Scotland. A wall at the edge of the known world; a fearsome, ­independently-minded people beyond it; sea wolves prowling mainland shores from island bases on the west coast; and many, many more besides.

READ MORE: The tenacious survival of the Douglases despite the revenge plot of a king

Yet the connections go far beyond ­surface-level comparisons. In creating the complex, embattled, ever-shifting history and politics of Westeros, Martin clearly did his homework. Its castles, like ­Winterfell and Riverrun, are scaled-up versions of real places and architectural styles. Its schemes, like the infamous Red Wedding, draw on age-old ­concepts like “guest right”, the unwritten law of ­hospitality found throughout the ­Highlands.

It’s not just the look of Game of Thrones that reflects ancient and ­medieval ­Scotland, it’s the way society and history function.

The “wildlings” living beyond the wall are the perfect example of this. ­Historically they combine prehistoric Scots with the Picts and indigenous tribes of the Arctic Circle. Superficially, they ­resemble the stereotypical Scot. Tacitus, a Roman historian writing about events in what is now Scotland, described the ­natives as having “red-gold hair and ­massive limbs”, which sounds like the ­beginnings of a flattering profile of the wildling Tormund Giantsbane.

It is the wildlings’ spirit, rather than their appearance, that speaks to deeper connections. Before the Battle of the Bastards between the forces of Jon Snow and Ramsay Bolton, a wildling warrior ­laments, “If we lose this, we’re gone. ­Dozens of tribes, hundreds of ­generations … we’ll be the last of the Free Folk.”

Here Martin drew from Tacitus, who put these now-famous words in the mouth of the Caledonian leader ­Calgacus ­before fighting the Romans at the ­Battle of Mons Graupius: “We are the last ­people on earth, and the last to be free. [The ­Romans] plunder, they butcher, they ravish, and call it by the lying name of ‘empire’. They create a desert and call it peace.”

The National: Reivers_raid_on_Gilnockie_Tower (G. Cattermole, Wikimedia Commons public domain.

Gilnockie Tower 

Scotland never had anything on the scale of the 700 foot-tall ice wall in ­Westeros. Yet, if we take the wall as a symbol of a more primal human anxiety rather than as a literal structure, then we can find an equivalent.

Two walls, built less than a century apart, marked the end of the world the Romans knew. There is Hadrian’s Wall, which is entirely in what is now ­England, and the Antonine Wall, built in the ­second century AD between the Firth of Clyde and Firth of Forth. A mere ­century after Rome abandoned Britannia, the things being written about these walls could come straight from Martin’s pen.

The Byzantine historian Procopius terrified readers with his account of the lands beyond, writing, “countless snakes and serpents and every other kind of wild creature occupy this area as their own … if any man crosses this wall and goes to the other side, he dies straightaway”.

In Game of Thrones, this stark division between life on one side of the wall and death on the other is vividly illustrated.

After a perilous climb of the wall, Ygritte stands atop its ramparts and looks out, for the first time ever, at the lands south of it. Permafrost gives way to green fields. Rootless soils transform into forests. The sun itself seems warmer, the patches of darkness less menacing. Looking north of the wall, the land is immediately gripped by ice. Fang-like mountains cast daunting shadows, and the barre waste seems to drain all colour and life from anything it touches.

It is a literal interpretation of ­Procopius’ semi-mythical picture of the lands ­beyond Rome’s walls. On one side is safety, warmth, life itself; on the other, peril, shadows, and death. It is not ­unlike how residents of Edinburgh referred to the walls that once defended the city, whose limits are now marked by a pub called The World’s End.

Geography plays a critical role in the events of Game of Thrones. Trying to lead his northern army to confront the ­Lannisters, Robb Stark must confront The Neck, a bog-drenched choke point. He could either go hundreds of miles around at great cost, or negotiate a ­

 crossing of the bridge guarded by the Frey castles of The Twins. To invade the south from the north or vice versa, every army had to reckon with this pinch in the ­landscape.

The National: Stirling Bridge (author's image).

Stirling Bridge

For most of history, this was the same conundrum faced by armies ­approaching Stirling. Prior to intensive drainage in the 18th and 19th centuries, the low-lying lands around Stirling were a great bog that forced armies to follow a narrow ­Roman road or else perish in the mire. The Firth of Forth was known through medieval times as the “Scottish Sea”, with a 13th century map by Matthew Paris showing Scotland literally cut in two by its waters, with just one crossing point – Stirling Bridge.

The geographical challenge faced by Robb Stark was the same that prompted William Wallace and Andrew de Moray to make their stand at Stirling Bridge, and which led Edward II of England to utter defeat at Bannockburn.

Staying with Bannockburn, there are striking similarities between a ­famous duel at that battle and the duel ­between Robert Baratheon and Rhaegar ­Targaryen at the Battle of the Trident in Game of Thrones.

Robert Baratheon was renowned as one of the greatest warriors in Westeros. Facing off against the dragon prince, he struck Rhaegar with his war hammer so powerfully that Rhaegar died instantly, the rubies on his breastplate scattered in the riverbed.

At Bannockburn, a young knight, ­Henry de Bohun, saw Robert Bruce ­giving a speech at the front of his army. Fully armed and riding a massive warhorse, de Bohun charged straight at the king. Bruce was lightly armoured, riding a small horse with only a hand axe with which to ­counter de Bohun’s lance. Bruce, ­however, was already reckoned one of the three greatest knights in Europe, and charged back. Rising in his stirrups, the King of Scots brought his axe down on de Bohun’s head with such terrible force that it split the knight’s skull “from crown to breast”.

You can still stand on the spot where this occurred over 700 years ago.

READ MORE: A family at war: the turbulent reign and assassination of King James I

One of the reasons that Westeros feels so genuinely “alive” is that evidence of its past is scattered across its landscapes. As a historian primarily of castles, I had to tip my hat to Martin here – Westeros is brimming with long-abandoned standing stones, cairns, hillforts, and castles, much like the landscapes in our own backyards.

Passing by the crumbling remains of a modest stone tower in A Storm of Swords, Ygritte remarks to Jon Snow that it must have been the house of a great lord. “It’s only a towerhouse,” he replies. “Some ­little lordling lived there once, with his family and a few sworn men.” Here, ­Martin shows his nuance. In many ­fantasy worlds, every castle is a massive, nearly impenetrable fortress larger than anything that ever existed in reality.

Not so In Westeros, where the majority of castles are what Jon Snow and castle historians call towerhouses. All but the strongest towerhouses would stand no chance against a proper army, and were only ever intended to defend against opportunistic raids like those launched by the 16th century Reivers of the Scottish Borders. This kind of detail elevates Westeros from a fantasy world inspired by our own, to one deeply informed by real history.

The power of Game of Thrones is in these kinds of parallels, and the way they make us think about the forces that shaped Scotland’s story. Reflecting on the value of fantasy to the human experience, George RR Martin said: “We read ­fantasy to find the colours again.” With such ­stories to prompt our sense of wonder, the history all around us becomes more colourful, indeed.

David C. Weinczok will be telling many more stories about Westeros and Scottish history at a talk on 3 March at Gladstone’s Land, Edinburgh, where copies of The History Behind Game of Thrones: The North Remembers will also be available. Reserve your spot now for just £4 via Eventbrite