Charles Dickens conjured up what his biographer Peter Ackroyd calls the "cosy conviviality" of Christmas like no one else has before or since.

He wrote around two dozen festive tales, including five books, but pre-eminent was, of course, A Christmas Carol.

Perhaps surprisingly, carols feature only briefly and incidentally, the most memorable moment being near the beginning. It's Christmas Eve and a cheerful young man leans down, peers through the keyhole of Scrooge's office and starts to sing God Rest Ye Merry Gentlemen, only for the old miser to seize a ruler (a well-known instrument of Victorian corporal punishment) "with such energy of action that the singer fled in terror".

Why name his supernatural tale of redemption A Christmas Carol? To emphasise the point, Dickens even called the five chapters "staves", a musical term for the verse of a song.

He hoped that, much like a carol, his story would warm hearts and make people think: as he put it, "May it haunt their houses pleasantly." Like a carol, his story evoked Christmas traditions such as merry-making, dancing, game-playing and feasting, while acting as a reminder of the pain, suffering, poverty and inequality that existed outside, beyond the frosted panes of happy homes, making an appeal for love and Christian charity.

It was also performed in public, just as Christmas music had been for centuries (carols had typically been sung in the street since the Middle Ages). A Christmas Carol was the first story Dickens read to a large audience, It became his favourite work for public performance, and the most popular. And of course it has that famous refrain: "God bless us, every one."

The components of Dickens's "Christmas Carol in prose" perhaps offer a clue to what makes for a good carol: a work that is accessible and memorable, and contains vivid imagery that encapsulates the Christmas message and a stirring chorus.

For many of us, carols are so central to our idea of Christmas that the season is unimaginable without them. Stopping in a bustling shopping street, scarves pulled up around our chins, to hear the Salvation Army band playing Hark The Herald Angels Sing; putting on Carols From King's while stuffing the turkey on Christmas Eve; and attending midnight mass or a Watchnight service to sing a few old favourites - these are traditions many people revel in, religious or not.

They evoke what is often called the "spirit of Christmas", the essence of the season as hard to pin down as a wisp of fog, but at the same time as powerful and unmistakable as the taste of Christmas pudding.

Many of the carols enjoyed in modern Scotland have their origins in English, German, French and other European folk tunes, or have come to us in the 19th century from the US.

They are loved here with just as much fervour as anywhere else, but Scotland has Christmas music of its own. There are in fact ancient Scottish carols, albeit only a handful, some of which are remarkably reminiscent of the traditional Christmas canon and could fit in a Dickensian tale without jarring with the sounds of a Victorian street. Others are haunting Gaelic tunes that conjure up the mystery and enormity of the Christmas story.

The term "carol" originally denoted not a Christmas song, but one that could be sung at any festival. In the medieval period, it was typically a celebratory song with a good strong chorus and was sung by ordinary people as opposed to accomplished church choirs. Often early carols had no association with religion. Over time, they started to be linked to the seasons (though not at first just Christmas) and became melded with religious music.

The reason for the comparative dearth of Scottish carols was the nature of the Scottish Reformation. Rebecca Tavener founded the Cappella Nova ensemble in 1982 with her husband Alan. It has championed early Scottish music ever since, producing 15 albums, including one devoted to Scottish Christmas music, and run a 25-year series of Christmas concerts.

Tavener says Scottish Christmas carols were probably sung up until the Reformation, but after that, many medieval music manuscripts were burned. "At the time of the Reformation, the new church was full of brilliant musicians but then the old Catholic church schools were closed, so traditions weren't getting passed on, they were dying out," she says. Fortunately, a few things survived in folk tradition and, at serious church music level, in manuscripts that escaped the flames.

Even so, the focus during the festive season in Scotland was not on Christmas. "Scotland has only comparatively recently taken Christmas music on in a big way; it was mainly focused on New Year." Christmas only became a bank holiday in Scotland in 1958. Probably the oldest Scottish festive song still regularly sung is Hac In Anni Janua from the 13th-century St Andrews Music Book. Dealing with the turn of the year into January, it is surprisingly modern, about making resolutions and moving on. It's a bit like a folk dance tune, as you might expect of a Hogmanay song.

Two of Scotland's most enduring carols date from the 17th century, probably owing much to that dwindling band of musical maestros trained in the pre-Reformation period. Nou Lat Us Sing started life as a welcoming song for James VI on his return to the Scottish capital after a period away and was then given Christmas words. Tavener describes it as "jolly, cheery, four-square street music". It is short, as is Ecce Novum Gaudium (Here Is New Joy). This is a delightfully simple, catchy Latin arrangement that overruns with Christmas spirit. Upbeat and triumphant, it isn't hard to imagine revellers clapping and swaying to it and, with a lovely brass setting, it would fit any modern Christmas programme.

The Gaelic folk tradition has produced some exceptional Christmas music. One of the best-known pieces, performed widely outside as well as within Scotland, is the painfully lovely Taladh Chriosta (Christ Child's Lullaby), a song from the Catholic tradition. Sung as if by Mary to Jesus, it has the quality of a lament (it was originally set to the tune of a Gaelic ballad called Grief For The Son Of Arois) but is associated with midnight mass in the Outer Hebrides.

The words were written by Father Ranald Rankin of Fort William for the children of his Moidart parish in the mid-19th century on the occasion of his departure for Australia (following many locals who had suffered crop failures).

The carol Child In The Manger, with words originally in Gaelic by Mary Macdonald, 1789-1872, and translated into English a few years later, is sung to the tune of what is now better known as Morning Has Broken, but is in fact a traditional Gaelic melody.

Balulalow, an old Scots word for lullaby, is another famous, touching Scottish carol written in the 16th century by poets the Wedderburn brothers of Dundee, who were religious reformers. They gave it the title Ane Sang Of The Birth Of Christ. It was arranged in the 20th century by Benjamin Britten (the most famous version, possibly drawing on the original folk melody as Britten often did) and Peter Warlock, though other musical settings also exist. Other distinctively Gaelic contributions to Christmas music include Of These Four Letters, referring to the spelling of "Mary".

The revival of these carols owes a lot to the late Kenneth Elliot, a senior lecturer in music at Glasgow University, who painstakingly transcribed forgotten Scottish music and got it into the public domain. "His life's calling was to make Scotland's earliest music available to everyone," says Tavener.

But she and her husband have not been slouches either. Cappella Nova has recorded the music and commissioned new music to augment it. "We commissioned about 30 new pieces, more than half of them from Scottish composers, to try to reinvent a Scottish music tradition." Because of this, new Christmas works now exist by composers such as Bill Sweeney and Rebecca Rowe.

Much Christmas music sung and played in Scotland today, however, is part of a wider western tradition. Many carols go on an evolutionary journey, crossing borders and picking up a bit here and a bit there. In his book Christmas Carols, released earlier this month, Oxford University music lecturer and choirmaster Andrew Gant points out, for instance, that English composer Ralph Vaughan Williams brought together transatlantic elements in O Little Town Of Bethlehem. He combined the words of a 19th-century American bishop, Phillips Brooks, who had been inspired to write them by the peace he found in the Holy Land after the carnage of the American Civil War, and an English folk tune Vaughan Williams heard sung in 1903 in Surrey.

Even some of the most popular carols, however, have surprising Scottish connections. The Wedderburn brothers, for example, wrote a set of words to the 16th-century carol In Dulci Jubilo. Angels From The Realms Of Glory brings together an old French tune and the words of a Scots-born campaigning newspaper editor of the early 19th century, James Montgomery, who built his journalistic career in Sheffield.

And there is thought to be a connection between the Jacobite rebellion and one of the most popular carols of all, O Come All Ye Faithful (Adeste Fideles). The carol has been interpreted as a coded message in support of the Jacobite cause. No one knows exactly where the tune or words come from, but it had turned up in the Benedictine Abbey in Douai, France, by the 1740s because that is where English Catholic exile to France, John Francis Wade, is thought to have found it. He copied it out several times and included it in volumes of religious music. It was published in England in 1781.

Back in the 1740s, however, the earliest of Wade's copies is devoted to "regem nostrum Jacobum" meaning James III, the son of the overthrown king James II and VII. Copies of the song were apparently often to be found in Catholic enclaves in Britain. Some researchers have suggested that "fideles", the faithful, was a term aimed at Catholics and that "born the king of angels" (regem angelorum) could be a pun on "king of the English" (regem Anglorum), as James was seen by supporters as the rightful English, and indeed Scottish, king, making the song part of the Jacobite ferment. If this is true, as Gant notes: "It was too subtle for the stolid Hanoverian brain. Nobody noticed. The hymn was happily accepted into Georgian society."

Arguably the most poignant rendition of O Come All Ye Faithful took place exactly 100 years ago, in 1914, during the famous Christmas truce in the trenches when German and British soldiers sang each other carols. One British soldier wrote "... we sang The First Noël, and when we finished that they all began clapping; and then they struck up another favourite of theirs, O Tannenbaum. And so it went on. First the Germans would sing one of their carols and then we would sing one of ours, until when we started up O Come All Ye Faithful and the Germans immediately joined in singing the same hymn to the Latin words Adeste Fideles..."

Songwriters add to the canon of festive music all the time, from Perry Como (It's Beginning To Look A Lot Like Christmas) to Slade (Merry Xmas Everybody).

But for many, the crooners, rockers and balladeers are froth on the eggnog; Christmas spirit is captured by carols, wherever they come from.

The album Nou Lat Us Sing - A Scottish Christmas by Cappella Nova, featuring 19 festive works, is available from the Scottish Music Centre for £15, Christmas Carols: From Village Green To Church Choir by Andrew Gant is out now, published by Profile Books, priced £9.99