AMID the reaction to the Paris attacks and Britain joining the bombing campaign against Daesh in Syria, it might be a good time to look back into our own history. Religious fanaticism and terrorism were not alien to Scotland.

One episode sets the scene. In May 1679, a group of nine men caught up with a coach carrying the Archbishop of St Andrews, James Sharp, three miles outside the town. After shooting the postillion dead, they dragged Sharp from the coach and hacked him to death in front of his daughter.

The killers were Covenanters, Presbyterians who opposed the imposition of bishops on the Church of Scotland by King Charles II and other measures aimed at bringing Scotland’s Kirk into line with the Church of England, in particular placing himself as head of the church.

Fundamentalist Presbyterians, or Calvinists who based themselves on the theology of John Calvin, might have found something of a mirror image in today’s so-called Islamic State. They put a stress on individuals reading and studying the Bible – education and self-knowledge was important to them and believers were encouraged to read and debate scripture. Idolatry was banned so their churches were plain, and there was no baroque hierarchy of religious leaders. Indeed there was a measure of democracy in how ministers were appointed and how the Kirk was run. Nevertheless, they held to the rigid and extreme views expressed so often in the Old Testament. During the late 16th century and the whole of the 17th, between 3000 and 4500 women were burnt at the stake, drowned and done to death after being tried in ad hoc courts (the figure for England was 1000 such deaths despite its much larger population ). Gay men were burnt to death on Edinburgh’s Castle Hill. Presbyterian Scotland in that time was not so far removed from the sort of Caliphate of Daesh.

Archbishop Sharp, once a Presbyterian firebrand himself, was made Primate of Scotland, charged with purging the church of ministers who refused to acknowledge the authority of Charles and the bishops.

More than 300 ministers quit the Kirk. Across parts of the Lowlands, they began to gather large congregations at outside services, Conventicles, outside the established church. The government ordered troops to break them up, but the Covenanters, as they termed themselves, resisted.

A brutal struggle between royal forces and the Presbyterian rebels ensued.

On 13 November 1666, near Dalry in Kirkcudbrightshire, government troops stopped and held an old man charged with refusing to acknowledge the new episcopacy. They threatened to strip him bare and to roast him alive in his own home but four fellow Covenanters intervened, shooting the corporal and taking the other three prisoners.

News of this took 24 hours to reach the garrison in Dumfries. Meanwhile the Covenanters had overrun the 16-strong government garrison at Balmaclellan and, on 15 November, with their numbers put at between 150 and 500, captured Dumfries, taking the government commander in his nightgown.

For the next week they moved around the south-west, threatening to march on Glasgow before deciding on Edinburgh, where they believed their friends were set to rise. Meanwhile the government commander General “Black Tam” Dalyell had been ordered to bring them to battle.

The Covenanters were ahead of Dalyell as they marched towards the capital, but discovered the city had been made secure by the crown. At Rullion Green, seven miles south of the capital, Dalyell caught up with them on November 24, where it took three charges for the regular troops to break the Covenanters, and when they did darkness afforded escape.

Nevertheless 120 were captured that day and 50 killed. Of those captured, 36 were executed in Edinburgh, with their heads and body parts put on display around Scotland. On the scaffold a captain in the rebel army, Andrew Arnot, prayed for his fellow accused, threw out a proclamation in support of the Covenant and then: “… pluckt out a pocket butt of sack and with a roaring voice uttered … that he would drink no more of the wyne till hee had it new in his father’s kingdome.”

The Covenanters believed they were on a fast track to heavenly rewards, though being Scots that included alcohol.

In June 1679 a further crackdown followed Sharp’s murder. A force of dragoons under John Graham, the Laird of Claverhouse, a royalist who had been in exile and had served in the French and Dutch armies, came across a Conventicle at Drumclog near Kilmarnock. Warned by lookouts, the minister told the women and children to depart and ended his sermon thus: “Ye have got the theory; now for the practice.” In the battle that followed Claverhouse was defeated, losing 36 men.

The Covenanters now advanced on Glasgow but internal divisions and the authority’s capacity to hold down the city meant they did not press the attack.

Eventually they faced the royal army at Bothwell Bridge.

Galloway men held the south side of the bridge for more than an hour, but on running out of ammunition were told to rejoin the main force, allowing the government forces to bring across the artillery. Under cannon fire the Covenanters broke. Some 400 were killed and 1500 captured. Seven of their leaders were executed and 250 who refused to submit to the crown were sent as forced labour to the West Indies. En route their ship sunk off the Orkneys and 200 drowned.

What followed became known as the “Killing Time.” Royal commanders went round the south-west demanding individuals swear loyalty to the king’s church. If they refused they were summarily executed.

In the years that followed, low-level guerrilla war took place across the region until the Glorious Revolution in 1688 brought an end to the repression. Some 90 Covenanters were executed.

During this period the Covenanter Alexander Shields came to the conclusion that the terms king and tyrant were interchangeable. Radical Covenanters began to advocate a Republic of Jesus Christ. One of the radicals, James Renwick, aged just 26, returned from exile and ventured to Edinburgh, despite there being a price on his head. He exchanged shots with government troops before being captured.

He mounted the scaffold and quoted to the crowd Revelations 19: “Come and gather yourselves together unto the supper of the great God; that ye may eat the flesh of kings.”

He then called out: “Lord I die in the faith that you will not leave Scotland. But that you will make the blood of your witnesses the seed of your Church, and return again and be glorious in our land. And now, Lord, I am ready.”

The overthrow of the House of Stewart, following the Glorious Revolution, led to the Church of Scotland reverting to a more Calvinist model (though the head of the church remained the monarch).

Throughout the 18th century it would strive to punish sinners through its own private courts, with the likes of Robert Burns forced to sit on the stool of repentance in church because of his sexual indiscretions.

While industrialisation in the 19th century weakened the Kirk’s hold it also brought immigration from Ireland and the rise of sectarianism, rooted in the Kirk’s anti-Catholicism and Scotland’s role in the subjugation of Ireland.

In 19th-century Scotland, Liberal voting members of the Kirk raised money to erect monuments to the Covenanter martyrs. Later, in 1937, a monument, paid for by public subscription, was placed in Edinburgh’s Grassmarket where some 100 Covenanters were executed, with the inscription, “Many Martyrs and Covenanters died for the Protestant Faith on this spot.”

On the left in the late 19th and 20th centuries, radicals and socialists would hold up the Covenanters as fighters for equality and freedom of speech, and opponents of royalty and aristocracy.

In Grey Granite, the final volume of the three-volume Scots Quair, Lewis Grassic Gibbon, one of Scotland’s finest novelists, has Ewan Tavendale talk of those "funny chaps the Covenanters", how "he had always liked them – the advance guard of the common folk in those days, their God and their Covenant just formulae they hid the social rebellion in.”

But for all their heroism and sacrifice they were fighting for a land ruled by the Presbyterian elect – with no room for unbelievers. Their dream for Scotland was not so far from Daesh's for its Caliphate.

Chris Bambery is the author of A People’s History of Scotland, published by Verso Books and available from booksellers