The author reveals his inspiration in the new audio guide for the castle.
It was a bloody double murder that marked the beginning of the end for one of Scotland's most powerful medieval families.
Now Game of Thrones author George RR Martin has revealed how one of the most graphic and grisly scenes in the hit fantasy drama was inspired by the notorious "Black Dinner" of 1440.
The 6th Earl of Douglas was only 16 when he and his younger brother David were invited to a feast with the young King James II at Edinburgh Castle.
During the meal, a servant entered with a black bull’s head on a platter - a symbol of death.
The King’s chancellor, Sir William Crichton, accused the siblings of plotting against James and they were dragged away, tried on a trumped-up charge and beheaded.
Martin, 71, has now described how that incident and the Glencoe Massacre of 1692 helped him flesh out his bloody Red Wedding scene.
The American novelist tells all on a new audio guide for visitors to Edinburgh Castle launched at the weekend.
In Game of Thrones, the HBO TV adaptation, the Red Wedding scene sees Robb Stark -- played by Scots star Richard Madden, from Elderslie, Renfrewshire - his wife (Oona Chaplin) and mother (Michelle Fairley) mercilessly killed.
In the guide to David’s Tower in the castle, Martin says: "Scottish history is amazingly bloody and dark and twisted and full of betrayals and battles, so it’s been a great source of inspiration.
"The Red Wedding, which is perhaps the most infamous scene in my book, was inspired in large part by two events in Scottish history - the Black Dinner here in Edinburgh, when the Earl of Douglas and his brother were murdered at a dinner given by the King, and the Glencoe Massacre, when the Campbells slaughtered the MacDonalds.
"I combined the two of those and threw in a wedding and you get the Red Wedding."
Martin is among a host of stars who feature on the new audio guide.
HES chief executive Alex Paterson said: "Edinburgh Castle is Scotland’s top paid-for visitor attraction, and we are committed to investing in the site and finding new and inventive ways of engaging a wide range of people with its history.