THE story of Cefnllys is one of war, struggle and defiance during the turbulent Middle Ages.

The village, near Llandrindod Wells, witnessed the destruction of its nearby castle - not once but twice - and would eventually become a ghost town.

The poet Lewys Glyn Cothi wrote: "A white castle above a full moat, An eight-sided fortress above a loop of the Ieithon, A Greek fortress with twelve girdles, The name of the place is Cefn llys, The name of that fortress is to be found In the great Brut of the Mortimers.'

The village was founded at the same time as the first stone castle was built on top of the nearby hill in the 1240s and had grown to gain borough status by 1304.

The population may have been small enough to fit within the enclosure of Castle Bank, a large ridge on which the Mortimer family built two 13th century castles.

By then it was home to a small mill and church while a manor and toll bridge were also built by the ruling Marcher lordship, the Mortimer family, to consolidate their hold on the ancient Welsh cantref of Maelienydd.

County Times: Castle Bank at Cefnllys. Picture by Julian Ravest.

The castle occupies a key position at the junction of several tributary valleys of the River Ithon, granting commanding views over an important communication corridor into central Wales.

Cefnllys was an administrative centre of Maelienydd, part of the Welsh region of Rhwng Gwy a Hafren until the English Marcher lords expanded their control westward.

Maelienydd formed a core part of the turbulent area known as the middle march, together with Gwrtheyrnion and Elfael and the castle was viewed as a forward defence against Welsh incursions into towns along the English border.

Cefnllys Castle became a symbol of Mortimer hegemony in Wales and was captured by the armies loyal to the Prince of Wales, Llywelyn ap Gruffudd, in 1262.

In late November 1262, Cefnllys was seized from Roger's constable Hywel ap Meurig by a small band of Welshmen, who entered the castle and took Hywel and his family captive, before sending word to Llywelyn of their success and torching the castle.

In response, Roger Mortimer led an army of Marcher lords and arrived at Cefnllys to start repairs on the walls, but was caught off guard when Llywelyn surrounded him with a larger force.

After a three-week siege within the damaged and unprovisioned castle, during which Llywelyn's soldiers sacked Roger's other castles at Bleddfa and Knucklas, Roger was forced to negotiate safe passage.

Llywelyn allowed the Marcher force to retreat before destroying the remaining defences and continuing his campaign against England.

Cefnllys featured prominently in the ensuing Treaty of Montgomery and the construction of new castle at the same site had led Llywelyn to refuse to swear fealty to King Edward I in 1275.

County Times: Castle Bank at Cefnllys. Picture by Nigel Brown.

The castle was once again targeted in Welsh revolts with Madog ap Llywellyn leading an attack on the hill fortress in 1294.

The natives had resented Edmund Mortimer and were granted an audience with King Edward I and parliament in London in 1297 and the appeal served to force the baron to restore the traditional Welsh court at Cymaron.

The authority of the Mortimer lords within Maelienydd was limited to the district surrounding the town and castle.

In 1306, the castle passed into the hands of Roger Mortimer, 1st Earl of March, who led an unsuccessful rebellion against Edward II which resulted in the confiscation of Cefnllys.

Roger returned from exile in 1326 and successfully overthrew Edward, briefly becoming de facto ruler of England alongside Queen Isabella, until he was executed in 1330 by Edward III.

County Times: St Michael's Church at Cefnllys. Picture by Bill Nicholls.

Repairs of the castle and its hall were carried out from 1356 to 1357 but the town was in decline with as plague outbreaks in 1349, 1361 and 1369 swept across Britain.

Meanwhile the constant threat of war with the Welsh princes had made Cefnllys a target for reprisals and by the mid-15th century the castle was in disrepair and the village virtually abandoned.

The death of Edmund Mortimer, 5th Earl of March, of plague in 1425 marked the end of the Mortimer male line and the castle was in ruins by 1687.

Cefnllys remained a borough after the decline of the medieval settlement but by 1831 when the population of the borough comprised of just 16 residents who resided in three farm houses and one small cottage.