Rhythm masters ... Malian music is a mix of traditional and modern sounds. Photograph: Kevin Rushby

We are on the sand, right in front of the stage. The Tuareg musicians swathed in blue scarves are warming up, and the crowd are loving it. This is the Festival on the Niger in Mali and the audience is almost as entertaining as the musicians: we've got everything from wild men from the backwoods to elegant city folk, and every age too - from toddlers to grandmothers. Among the foreigners, backpackers are in the majority, but there are older people, too.

"You know," shouts a sixtysomething book-dealer from London who is next to me, "I haven't freaked out like this for 20 years." It's true, it's impossible not to dance, and the packed crowd is going for it - 15,000 people on their feet and enjoying some of west Africa's greatest music stars.

I am on a visit organised by the world music magazine, Songlines, a tour that started with the music scene of the Malian capital, Bamako, before moving 200km up country to the festival by the river Niger. I had expected good sounds, but what I had not predicted was that we were about to get a privileged insight into a country and its culture, one that only music can provide.

Many Brits first became aware of Malian music with Andy Kershaw's "discovery" of Ali Farka Touré back in 1986. Since then we've had Martin Scorsese's The Blues, tracing lineages from the Mississippi delta back to Bamako, plus Damon Albarn's championing of various artists and dozens of magical moments provided by record labels like World Circuit. African instruments such as the kora (a double-sided harp attached to a fat calabash) and the n'goni (like a banjo on a diet) have become regular sights at festivals such as Womad. Bamako's main kora-making family, has become used to the internationalisation of their art : "Do you want kora lessons in London?" asks Amadou Diabeté as we tour his backyard workshop. "I can give you a telephone number."

At first sight, Bamako is not one of Africa's great cities. A sprawling centre-less tangle that straddles the broad river Niger, it does, however, have some redeeming features. One is the Grand Marché, a chaotic extravaganza that encompasses everything from woodcarvings to Saharan rock salt, traditional medicine to indigo cloth. Overwhelmed by the choice available, I didn't actually buy anything on my first visit, but I did get a shoeshine and a lesson in how to play mancala, the ancient African board game.

The capital city's second redeeming feature, the nightclubs, are just as diverse and vibrant. The first spot we tried was the Parc du Prince Club on the far side of the Niger. The house band, Groupe Idris, were on sparkling form, with musicians from the audience jumping up to jam with them. One of their songs, I was told later, was about Sunjata, a Malian king of the 13th century. I suppose the British equivalent would be Coldplay singing about Henry VIII.

That's the Malian musical alchemy in action: the electrifying mix of old and new, of youthful spontaneity and venerable tradition. When some VIP appeared in the crowd, the vocalist began to sing his praises, quite literally, belting it out with all the passion that the reverend Al Green reserves for the Lord. The roots of gospel soul are deep in such African praise-singing, a sound that the traditional bards of Mali, the griots, have used since the days of Sunjata. Unlike Al Green's Lord, however, the VIP was obliged, by time-honoured tradition, to pay handsomely for his unsolicited panegyric.

The next night we hit Djembé, a club with an extraordinary echoing sound system that harks back to the glory days of the 60s and 70s when Africa was jumping with independence fever. There is no shortage of choice: Bar Bozo, the Diplomat (check for top kora player, Toumani Diabeté, on Friday nights), Espace Bouna, Moffou, Blonba and many others. The French Cultural Centre is a good spot to check out what's on, and to have a decent meal.

At the Djembé we watch Mamadou Cherif Soumano get up from the audience, fetch his kora, and jam with the house band. Cherif is something of a celebrity, having played with stars of jazz and reggae, but in Bamako musicians dive in and out of each others' bands with an easy egalitarianism.

As luck would have it, and in the way of things in Mali, Cherif is a friend of our guide, Sarah, and agrees to come with us to see one of Mali's most important historic sights. Next morning, not too early, we pick up Cherif and head south-west, following the low cliffs that mark the limit of the Niger Valley. At the village of Sibi we pick up Doumbia, a storyteller, then start walking into the hills. The path curls around great rounded red boulders, climbing up on to an escarpment where we get great views across the Niger plain. All the while Doumbia is winding his tale around the landscape. We stop at a cave where Sunjata, the great Malian hero, first discovered the power to transform himself into a lion, then another cave where women pray for fertility, until, finally, we reach our destination: the huge rock arch of Kamdjan where, according to legend, a sorcerer flung a magical arrow. Cherif intersperses each story with a burst of kora playing and slowly a longer tale emerges, the epic of the birth of Mali and the great king, Sunjata, who founded the Mandé Empire back in 1235. This historical moment is the bedrock of all subsequent Malian culture.

Though caste-based and slavery-driven, the Mandé was a cultural success. A caste known as the jalis, or griots, became praise-singers, a practice that required them to have detailed knowledge of Mandé genealogy and history. The griots were like musical weavers, binding everyone together in knots of kinship and duty, even undertaking mediation in disputes. They were also a musical balm, soothing the egos of the wealthy while charming them out of their excess riches. It is the griot tradition, passed down the generations ever since, that gives Mali its vital musical resource: a natural community of trained entertainers.

After another musical extravanganza that evening, we head out next morning to the Conservatoire des Arts et Métiers, a government-funded institute that demonstrates how central the arts are to Malian society and its future. In a country with precious few natural resources, its culture has become one of its few successful exports.

The Conservatoire students put on an impressive singing display and then sit down to chat. I'm keen to know where the griot tradition fits into this modern centre, with its sound studios and workshops in computer animation and installations. The students I meet, however, are all from non-griot families.

"My father was dead against me studying music," says Cheick Diombano, a talented guitarist and singer. "We are not a griot family and he said that only griots should sing - it is very hard to break with that tradition."

It may be hard, but a few have managed. Salif Keita, for example, probably Mali's most famous singer, fought against the prejudice of being both non-griot and an albino. Others like singer Oumou Sangaré come from the Wassoulu, a community south of Bamako who have deliberately broken the griot monopoly.

Later that day, walking through one of Bamako's markets, I get an unexpected demonstration of this non-griot music. There's a man dressed in mud-coloured clothes, patched and stitched with strange charms. He's carrying a kamalen n'goni, a six-string guitar made from calabash, broom handle and an old milk tin. He's a hunter, Sarah explains, and they have their own songs. The sound he makes is certainly not sweet: a roaring, driving hatchet job of a song, delivered at full blast inches from my face.

That evening we find ourselves in Bar Benediction to see Kasse Mady Diabeté, one of Mali's top male singers and a man who has never quite cracked the foreign market. Malian musicians seem to produce their best sounds at home: the effortless soaring vocals bring roars of approval from the audience. In response, Kasse gets even better. The intensity rises. Kasse then brings on his daughter, a formidable singer in her own right - a future star, no doubt.

Sarah has exceeded all expectations of the music buffs in the group, but there is one treat left before we head off to the festival the following day. This time it is Cherif who has pulled off a coup: a visit to the house of one of Africa's legendary musicians, Djelimady Tounkara, the guitarist with Bamako's Super Rail Band and veteran of several visits to the Womad festival in the UK. We find him sitting in a small living room off the yard, strumming on his battered sunburst acoustic. He chats about his next venture - a band featuring guitar and three n'gonis - then gives us a song.

Music festivals seem to be a recent innovation in Mali. Most renowned is the Festival of the Desert, held 70km east of Timbuktu, but the Festival on the Niger held at the town of Ségou, 200km from Bamako, is catching up fast. On arrival we are treated to a small, private concert of local musicians: it's a chance for us to hear many of Mali's traditional instruments, and to try them out. Carried away with the experience I end up buying the balafon - a xylophone built over a series of suspended calabash sounding boxes.

Ségou kicks off with hours of speeches from dignitaries. Eventually, however, the crowd jumps to its feet, and a three-day bonanza of Malian musical talent begins. Between sets the town is just as entertaining: craft-sellers, buskers, music-lovers, plus all the spectacle of life on the banks of a great African river. On the final night, Vieux Farka Touré, Ali's son, gets the crowd warmed up for the stirring finale from Mali's greatest diva, Oumou Sangare.

As our group prepares to return to Bamako, any sadness at the end of the festival is counterbalanced by Sarah's announcement. She hopes we don't mind, but we're going to have lunch with Vieux Farka Touré - and he's bringing his guitar. Nobody seems to mind at all.

We're jamming: A brief guide to Malian music

Ali Farka Touré,who died in 2006, remains Mali's best known musician: try his last album Savane or his collaboration with Ry Cooder, Talking Timbuktu. Ali's son, Vieux, one of Mali's rising stars, is playing at the Jazz Cafe in London (jazzcafe.co.uk) on 23 May. Others include Bassekou Kouyate, an electrifying n'goni player whose album Segu Blue was produced by Lucy Duran, presenter of BBC Radio 3's World Routes.

One of Mali's older stars is Salif Keita, who made his mark singing with the Super Rail Band de Bamako in the 1960s. His 2002 album Moffou was seen as a return to form after a period of over-glossy production (Moffou is also the name of his club in Bamako). Another big hit of recent years was blind couple Amadou and Mariam's album Dimanche à Bamako.

Among Malian women there are two firm favourites, not just for their vocal brilliance but for their forthright views on issues such as polygamy: Babani Kone and Oumou Sangare (who has a new album, Seya, out on World Circuit).

The Tuareg people from the northern deserts of Mali have produced some great musicians, notably the group Tinariwen (on tour in UK from 18-28 March, tinariwen.com) and female singer Heira Harby. One of the singers who impressed on the Songlines tour was Kasse Mady Diabate, who is playing at the Barbican in London on 6 April (barbican.org.uk) with Senegalese supergroup Orchestra Baobab.

Way to go

Getting there

Songlines Music Travel (020-8505 2582, songlines.co.uk/musictravel) is running a 10-day tour of Mali, including the night clubs of Bamako, instrument-making workshops and Ségou, from 17-26 October. It costs £1,249pp, plus £600 for flights from Heathrow. Songlines' 2010 Festival on the Niger tour runs from 23 January-1 February and costs £1,299pp plus £600 for flights.