ITWAS the biggest event hosted by the Edinburgh International Conference Centre. More than 3000 people of all ages crowded into the building, until the doors eventually had to be closed. The buzz around the place was palpable as clowns, musicians and actors mingled among the punters who went up and down the escalators looking for the event of their choice. The day, which lasted from 10am till midnight, exceeded all expectations.

Who organised Saturday's sell-out?

Was it the StarTrekkies' global reunion committee? Was it Live 8 International? No, it was the Church of Scotland. Yes, the old Kirk. Coming after a General Assembly week dominated by gloomy headlines about numerical decline, this national celebration - the biggest church gathering in Scotland for 50 years - provided a paradoxical counterpoint. What is going on?

Pundits have predicted the demise of the Kirk in about 30 years. So was the weekend event simply the spectacular twitching of a worn-out patient in a terminal ward, or the harbinger of something new? Read on, Macduff.

The great days of Scotland's national church were - apart from the era of the founding fathers - in the 1950s. An influential Kirk had a signed-up membership of 1.3 million, a staggering figure. It has since lost about 800,000 members. Why?

The general perception is that the Church has not been "modern" enough. The reality is somewhat different. The "modern" period dates roughly from the mid-eighteenth century. Far from being swamped by the modern era, the Kirk actually made a brilliant response to it. Tremendous theological vigour was matched by preparing sweeping, confident plans for mission at home and abroad.

By the late 1950s, however, the fairly settled institutional life of Scotland had started to crumble. Patterns of work began to change radically. The great mass-membership movements - the political parties, the trades unions - lost much of their power and appeal.

People became more aware of other philosophies, other religions. The feminist movement and the sexual revolution irrevocably changed the way people related to one another.

The "modern"world was starting to die. The pervasive changes are lumped under the heading of "postmodernism" - which is basically a way of saying that we sure as hell don't knowwhat's going on, but it's different from what's been happening. Postmodernism is shorthand for a whole new shift in the way we live and think about our lives.

What of the Kirk in the midst of all this? Like other mainstream Scottish institutions, it was caught up in a whirlwind it didn't understand. The Roman Catholic Church in Scotland saw the figures for attendance at Mass go into free-fall, and vocations to the priesthood drop.

The Scottish churches are, in fact, "modern" institutions with centralised structures, trying to stand upright in the postmodern hurricane. The first institutional reaction to the crisis was the classic modernising solution of reorganisation. "I was to learn later in life that we tend to meet any situation by reorganising, and a wonderful method it can be for creating the illusion of progress while producing confusion, inefficiency and demoralisation."Thus wrote Petronius Arbiter in 60AD.

But the postmodern church crisis ran much deeper. With the collapse of confidence in rationalistic solutions, the rise of relativism posed a serious challenge to the apparent certainties of modernism. On what grounds could one metaphysical or ethical statement be judged truer than any other? Abandoning a restrictive religious heritage, many sought spiritual fulfilment in NewAge nostrums. The big flat-footed churches looked like bewildered dinosaurs in an age which celebrated lightness, f lexibility and choice.

The old Kirk conveyer belt which carried young people from baptism to Sunday school, to youth fellowship, to confirmation, to church marriage, to baptism for their children, ground to a halt. In a culture which emphasises images, wordy European churches, with their propositional creeds, have taken a battering. Protestant and Catholic churches were perceived as hating a new world they didn't understand. Hence the exodus, hence the apocalyptic warnings. Institutions which haemorrhage numbers are inevitably doomed.

On current trends, that is. What the Church Without Walls group within the Kirk has done is to say that when things fall apart and the centre cannot hold, the really creative change may happen at the margins. The task of the Kirk, they believe, is to re-imagine the gospel of Christ in contemporary terms, and to find imaginative ways to live out the core message.

Statistically, the average church member was born BC (before computers) , reared on books and libraries and used to linear thinking. No wonder Mr and Mrs Kirk, bewildered by their children's rejection of what they held dear, feel themselves to be aliens in their own land and time. They could easily echo the words of Marx - Groucho - "God is dead, man is dead and I'm not feeling too well myself." By the Waters of Leith we sat down and wept.

What is springing up in the cracks and interstices of an old church is an intriguing growth. This new movement hangs loose to certainties and structures which have lost their authority, and welcomes interesting fellow travellers on the way. It stammers ancient truths in new and strange tongues.

There is, of course, a danger that the core message of Jesus will be lost in translation. He who marries the spirit of the age will be a widower for a long time, runs the wise epigraph. But the truth is that the Church has repeatedly had to reformulate its beliefs in terms of the prevailing culture.

There are other straws in the postmodern wind. It is increasingly evident that the consumer culture can deliver geegaws but not happiness, material goods but not meaning. Individualism without community is seen to be empty. And a lot of NewAge religion is drowning in its own shallow waters.

Does that mean that thoughtful people will flock back into the old Churches? Pass. Certainly not to Churches which hector people, marginalise women and stick the boot into gays, orwhich still hanker after the power and baubles of a Christendom which has rightly had its day. What the mainline Churches do have to offer, even amid their own manifest f laws, is two millennia of spiritual riches. Their job is to keep alive the rumour of God, and share out the treasures.

Will there be a revival of mainstream religion? God knows. The answers are blowing in the wind of the spirit. All I can report from the Edinburgh front line is that this gathering did not represent a sour and disappointed Presbyterianism which rails at people because they refuse to play by the old rules. This was a lively and encouraging sign of an old church trying to sing an imaginative new song in a strange land, a land in which the cultural tectonic plates have shifted, and things will never be the same again.