In 1987, Tom Gallagher published a book entitled Edinburgh Divided:

John Cormack And No Popery In The 1930s. The study of a grubby local phenomenon caught many eyes by rebutting the strange, persistent notion that "religious unrest" had never been the capital's kind of thing. Real hatreds, ran the myth, belonged "in the west".

When the book appeared, I thought I knew something about Cormack and his "Protestant Action". What I knew was folk memory. Some trouble at the Usher Hall? Some sort of riot up in Morningside? Some miniature demagogue down in Leith getting himself on the council by claiming that Catholics got their pick - quite how was mysterious - of council jobs and houses?

Gallagher's tale was more substantial than any legend. On his first page he quoted Willie Gallacher, Communist MP for West Fife, stating in the early 1930s that "in Scotland the Fascists are not anti-Jewish but anti-Irish". The author noted the identification of religion with nation, but as Gallagher explained, this was not new. The Kirk had been campaigning for years against Irish - that kind of Irish - immigration.

Cormack, predictably, was a vicious populist with an eye for headlines and no regard for any species of truth. Though vehemently anti-socialist, he knew there were few votes to be had from that sideline. Gallagher's study further inquired whether his subject knew enough about faith even to be styled a Protestant. But the former soldier, who had served in Ireland after the First World War, could incite violence with the worst of them.

So Cormack grubbed for votes in the depths of the Depression and gained some attention: what of it? The type was active across Europe. But this character could attract 3000 people to a meeting at the Usher Hall. In municipal elections in 1936, Protestant Action took 31.97% of the Edinburgh vote, kept Labour in third place and returned nine councillors. Then there were the "disturbances" in Morningside.

There has been an interesting enthusiasm among some of Gallagher's fellow historians to show that events surrounding a Eucharistic Congress in the hot summer of 1935 were not "really" a riot. In this version there was merely an attempt by a mob of 20,000 to besiege Catholic adherents while street fighting broke out and police batons were drawn. The authorities, it is said, were always in control. Whether they were everywhere present is another matter.

The question over Cormack might be this: what drew those 20,000? What then caused 35,000 to vote for Protestant Action? Again, you can find explanations that ring down the decades. Boredom; frustration; curiosity; the entertainment value of a scandalous orator; the ancient appeal of scapegoats. Very plausible. It couldn't have been that numbers of people in John Knox's city were convinced and contented bigots?

Cormack reappears in Divided Scotland, as he must in a history covering 200 years. For the present, Gallagher wants to know why sectarianism persists in a secular society; why "new tensions" have appeared since 2010; and why "anti-Catholicism remains an option that is acquiring respectability of the kind that it has never had for almost a century". His context is the insistence, often heard in academia, politics and the media, that hatreds named for religions are things of the past, now rare or irrelevant.

Gallagher is certainly not of that view and neither, interestingly, are Scotland's biggest churches. The Roman Catholic church, and Catholics such as the composer James Macmillan, have continued to insist that sectarianism is a fact of life. The Church of Scotland, no doubt mindful of its institutionalised bigotry in the first decades of the 20th century, has shared much of the analysis. Yet how can that be true in a country in which religion has withered?

You could as well ask why John Cormack was fierce for his "Protestantism" while showing little interest in faith. It would be a version of another old statement of the obvious: whatever creates bitterness between two Glasgow football teams, it can't be blamed on God's places of worship. Gallagher instead accepts the view advanced by the educationalist Walter Humes that Scots are disposed to tribalism, that this is a country divided in more ways than we care to recognise.

Even in a secular society, "religion" remains a handy makeshift identity, a badge of cultural identity (chosen or not). In other words, the churches confuse their interests - and problems - with what goes on among nominal adherents who have not been near a church since childhood. Here too is a version of an old saw: are you a Protestant atheist or a Catholic atheist? Most people get the point instantly, but the point has nothing to do with the hierarchy or the general assembly.

We should attend, though, to Gallagher's sub-title: Ethnic Friction And Christian Crisis. The author believes that those he terms secularists have been in open, sometimes conscious competition with the churches for social and political leadership while religious observance has become a minority interest. The churches themselves, particularly the Catholic church, have meanwhile not lacked for problems.

Again, this appears paradoxical. If secularists have won, why would sectarianism persist? If individuals not institutions are the real victims of prejudice and worse in daily life, given the fall in church-going and the end of "Protestant Scotland", why should the institutions complain so loudly? The claim that there is a deliberate secular assault on religion - as opposed to an attempt to maintain a separation between church and state - is arguable. The godly who talk of "oppression" are rarely plausible.

Gallagher has a point, for all that. Set aside the complaints of churches as power, influence and deference is denied to them. In a modern, apparently post-religious Scotland intolerance - most of it from a supposed majority towards a minority - continues. Given that fact, the abolition of "faith schools", the usual simplistic demand, is beside the point and a selective sort of panacea. Besides, what variety of secularism, claiming liberty for all, engages in suppression?

In Divided Scotland, Gallagher tells his story concisely and well. In the later pages of the book he is too indulgent of the "failings" of certain clerics, however, and of their abuses of power. He is too ready to believe that if the twin pillars of Protestantism and Catholicism come to dust only an all-powerful "activist state", armed with an "insubstantial secular blueprint for organising society", can remain.

So a long history comes to a brief, pessimistic and slightly bitter conclusion. Gallagher cannot envision a Scotland without a "moral community" provided by churches. His distrust of the Holyrood parliament, its parliamentarians and their alleged designs is palpable. He tells the story of sectarianism to show, in his final words, "that its staying power does not stem from religious factors alone". Crudely: keep God out of it.

If that's true, you might wonder why Scots, supposedly natural-born tribalists, have not yet found other reasons for division and hatred. Gallagher's history is part apologia and part Philippic, but it does not provide an answer. Yet if it does not convince this reader at every turn, its intellectual commitment is impressive. With more rigour of this order, our waning churches might be a less fretful as the twilight approaches.