Rome is famous for its ruins, the broken pillars of villas and temples intruding on everyday life, but the borderlands between Scotland and England are equally littered with remains from the past.

Here, history lies on all sides in the form of fortresses, glimpsed between trees or glowering over villages, or turning to dust by the road. Many of these buildings have crumbled to rubble, but a few are still grimly intact. Nowhere else in Britain was so heavily defended, nor needed to be. From Berwick and Bamburgh to Gretna and Carlisle a string of castles, keeps and peel towers form a barbed wire necklace that serves as a reminder that in this region not so long ago thick walls and dungeons, gunloops and ramparts were more important than comfort and warmth.

Harbottle Castle was one of the least welcoming. Though no longer dark or forbidding, it reeks of bygone days. Nine miles north-west of the elegant market town of Rothbury, and on the edge of the village that shares its name, the castle is now a smattering of tumbledown walls that rise against the sky. There is a lot of sky here, in the heart of Northumberland.

Built in the 12th century on the orders of Henry II, Harbottle was once one of the most important strategic castles in the area, an outpost of the warden of the Middle March. More importantly for my purposes, it was also the part-time residence for many years of one of England's most audacious and powerful robber barons. Thomas Dacre was the Warden General of the English marches under Henry VIII, and Harbottle was where he kept control of the middle and eastern territories, which were in constant turmoil. A man who probably believed that in the north he was more important than the king, his homeland was in Cumberland in the west. Naworth Castle near Carlisle was his seat, but for much of the year he was obliged to be at Harbottle, which clearly irked him. To read the records of the time is to learn that even for a soldier as ruthless and powerful as Dacre, it must have felt as if every man and woman in the neighbourhood were a grain of gunpowder, perpetually ready to blow. As Dacre tartly responded, when accused of encouraging crime, "many of the inhabitants of Riddisdale [Redesdale] were thieves, and so they were before ever I had any rule there".

As almost every officer charged with maintaining order in the area quickly learned, national loyalties were as nothing compared to those of clan. The king's representative was less a figure of respect than a tempting target for the bands of thugs who liked to think the region was in their control. As a result, Dacre formed dangerous associations with some of these gangs, to aid him in keeping the peace. They in turn helped him grow rich.

All this I had known, though not in detail, before reaching Harbottle. When I saw the remains of the castle, however, this turbulent age was brought out of the pages of history to become tangible, and terrifying. Until now, I had had only a rough idea of the sequel I wanted to write to my novel After Flodden. I knew the characters and period - ten years after the battle in 1513, when Scotland was in political limbo - but little more than that. Now a story began to take shape.

The castle lies in a hollow of hills, like a crouton in an empty bowl of soup. When it was built, its keepers could have seen for miles in every direction, across the empty peaks. Although this dale is beautiful, with its gentle hills, lush woodlands and the sparkling River Coquet, where the castle stands the prospect is bleak. Everything around it, including the wind-bent trees, speaks of the harshness of the people and their lives in former generations. For Dacre, keeping control of this region was a sore affliction. But there were compensations. When in 1515 James IV's widow, the heavily pregnant Margaret Tudor, was being hounded by her enemies, she fled in the middle of the night from Linlithgow Palace to Harbottle, leaving behind her very young sons James V and Alexander. Baron Dacre was a close ally of hers - her affectionate relationship with him long outlasted that to her second husband - and he not only offered her shelter but, once the baby was born, invited her to relocate to his splendidly furnished castle in Morpeth, where she could recuperate in luxury. What his wife made of this we can only guess.

Harbottle was never luxurious. On the bright summer's day when I first visited, the wind was chilly. When Dacre was its master, he and the hundred soldiers stationed there would have had to endure cold, damp and increasing dilapidation. It did not even have kitchens or a brewhouse worthy of the name. Some years later, a local inspector bemoaned: "Castle Harbottle is for lack of repairs fallen into extreme ruin and decay - a great pity to see." He estimated it would cost £400 to fix but added, "the owner has no wood to repair it, and none grows in the area, except in the king's Rothbury Forest. If not soon repaired it will soon be uninhabitable."

As today's grassed-over remnants show, the repairs were not made. The same is true of countless other fortifications along the borderline, and as the story of Dacre and his conflict with the border clans started to emerge, so my interest in these places grew. They might look like broken teeth, but they are illustrative of the menace that was the hallmark of this ungovernable region. Among the most unnerving, which I had used as a setting in After Flodden, is the forbidding Hermitage Castle in Liddesdale. Made of sheer stone, it holds possibly the most miserable position within these islands, in a wasteland of moors where only the desperate or the murderous would have wanted to live. I have a photo of my husband posing like one of Three Musketeers on one of its broken staircases. Had he fallen into its dungeon, he would not be looking so amused.

Hermitage does not feature prominently in my sequel, Dacre's War, but other towers and castles do. Crozier's Keep is the stronghold of the Crozier clan, whose leader Adam is bent on avenging his father's murder at the hands of Dacre. This gaunt, cold fortress has its origins in a peel tower I first saw as a child. Smailholm Tower is more like a doll's house than a castle, built on a miniature scale compared to Harbottle or Hermitage. A narrow, three-storey tower house with nine-foot-thick walls, it dates from the early 16th century, when Crozier and Dacre were in their prime. A few miles from Kelso, it sits on Sandyknowes Craigs, a hard-bitten outcrop, and was a strong influence on the imagination of one of the finest-ever historical novelists, Sir Water Scott who, as a young boy, stayed on his uncle's farm nearby. In his epic poem Marmion, about the battle of Flodden, Scott referred to it as "that mountain tower/ which charmed my fancy's wakening hour". He was not alone.

As a youngster, picking my way towards it through dandelions and sheep, and finding a view of the Cheviots, Lammermuirs and Eildons when I got there, I could think of nothing more thrilling than living somewhere like this. It's no surprise then that when the time came to create a home for Adam Crozier and his clan, Smailholm was in my thoughts. Though Crozier's Keep perches on the lip of a cliff, and is ten times its size, it has the same domestic appeal which, even to those of us used to central heating and hot water, is still strangely alluring.

There are almost as many border fortifications as there were reivers, but the viciousness of the 16th century can be found in other shapes too. There is a quiet corner of Northumberland where I sometimes visit, which to my surprise I found mentioned in an account of the early 1500s. Barrasford is a hamlet, lying beneath Haughton Castle, on the banks of the North Tyne. Like many places in those days, it had to defend itself against marauders, both local and Scottish, who would ride out at night - especially when the moon was full and the harvest newly brought in - and pick the place clean. A village was lucky if the raiders did not leave it in flames after emptying its barns and driving off its stock. Thus two guards were set on watch from sundown to sunrise at Barrasford to sound the alarm in case of intruders, each watchman paid fourpence for his shift. Now, whenever I stay there, I think of those men as I turn in for the night, and what it must have felt like to be posted on the bridge, listening for the sound of hooves.

The gaol at Harbottle was not big or strong enough to hold the number of captives Dacre and others took, and so they were often marched or taken by cart to places such as Hexham or Morpeth. Hexham prison, it seems, was something of a joke. Court records suggest that since anyone could walk right up to it, escape was frequent. Sometimes inmates were allowed to roam the town by day, and expected to return meekly, like sheep, to be locked up for the night. Against the odds, many did just this. One has to assume that damp and draughty though their cells were, and despite the meagreness of the rations, it must nevertheless have been more inviting than their usual haunts.

To be banished to Morpeth, however, was almost as good as a death sentence, as all reivers and thugs knew. A few of the most daring managed to liberate their companions, but such triumphs were rare, and risky. This would explain Dacre's account of a not uncommon occasion, when his men were transporting Scottish captives from Harbottle to Morpeth, and were caught in an ambush. The prisoners escaped, three guards were killed and the gaoler and the bailiff of Morpeth were taken hostage. They were not returned for months, and only then after long negotiation. Reading between the lines, it seems possible that Dacre had a hand in the attack, for all his protestations of innocence.

Yet protest he must. Little has been written about this man outside academic history books, despite the power he held, but when I began to dig deeper, I discovered a soldier and diplomat as fascinating and talented as he was corrupt. As a young lord he had annoyed Henry VII with his belligerence and arrogance, picking a fight with a rival army that nearly led to a diplomatic crisis with Scotland. To dampen his spirits Henry threw him into the Fleet prison for a few months. Much later in his life, in the period when Dacre's War takes place, he was again summoned to the special court of Cardinal Wolsey, known as the Star Chamber, to answer accusations of collusion with border criminals. In court proceedings, and in personal letters, the baron's voice is as loud and indignant as if one were in the room with him.

By this time he was already taking shape as a fictional character, but it was one particular detail that caught my eye. Ordered by Henry VIII to harry the Scots on the border, Dacre was involved in the destruction of several of the abbey towns, such as Dryburgh and Melrose, whose lace-like walls and blackened windows carry an echo of those times. On one of his deadly excursions, he and his army left Jedburgh ablaze. Later that night, while the English were camped out in the nearby hills, the borderers took their revenge in a peculiarly savage and original manner. That this was the stuff of fiction was evident. But it was when I read that Dacre was afraid of the dark that the plot finally slotted into place. What was he scared of, and why?

EXTRACT

At the bugler's cry, Harbottle castle came alive. Soldiers dropped their dice and raced to the gates, stable boys crammed the remains of their evening meal into their mouths before scurrying to their stalls, and sentries streamed from the barracks to crowd the walls. With the groan of a ship about to break up in a storm, the drawbridge was lowered.

Far above them, Francis Blackbird watched from the ramparts as his master returned. He knew at once that something was wrong. The baron was not at the head of his men but out on the wing, riding as if the army he was bringing home were invisible, and he alone was cantering through the early autumn evening off the hillside and into the greensward fringed by trees where Harbottle stood, a haven in the heart of rebel territory.

On the walls, the guards' helmets glinted as if they'd been struck with a flint. The flashing steel was echoed in their gimlet stare. By day, nobody could approach without being seen. Allies were anxious as they drew close, fearing they would be taken for foes; enemies were rarely able to reach the gates before they were chased off by arrows or shot.

The baron's men swept into the castle, steam rising from their horses as if it were the depths of winter and not a golden warm day. Wild-eyed and raucous, they were in good spirits after a week of fighting, but his lordship was wrapped in brooding silence, his mood visible even from Blackbird's lofty lookout as he flung his reins at a groom, and strode up the ramp and into the castle without a word.

His butler feared a difficult night lay ahead. While the army birled around the courtyard as if at a dance, unsaddling their horses and shouldering packs heavy as the dead, Blackbird hurried down the turnpike stair to the baron's private quarters. By the time his master reached the top floor, a fire was burning in the grate, a sprinkling of herbs sweetening the dank fortress air, and fresh hose and shirt lay on the bed, awaiting their weary owner.

Herald readers can order Rosemary Goring's new novel Dacre's War for the special price of £12.99 using the code DACHER2015 with free P&P anywhere in the UK. To order, simply phone 0845 370 0067 or log on to www.birlinn.co.uk. This offer is valid until the end of June 2015.