SHORTLY after we moved to Leith, I noticed some graffiti on our street saying "Martin's child, drugged, raped, murdered". I had only just had a baby and wondered, momentarily, about what kind of place I had brought my family to. Soon afterwards, on my daily excursions up Leith Walk, I began to notice other more esoteric messages on the walls, a series that included: "Do not be afraid." "I sent you flowers, you wanted chocolates." "Dante called her Beatrice." Soon I was photographing and recording almost every graffiti scrawl: not just this set of lines and lyrics, but also the tags, the declarations of love, the stencil images, the hate-fuelled rants.

I am not the only person to have done this. Look on the web, and you will discover that graffiti often has its life extended through photographs on virtual walls. Leith, the area I focused on, isn't known for its graffiti. But there is, on its buildings, the regular cacophony of different voices. Dianne is gay and proud. Kill Brit Beast. Mel Brown lvs Callum Trainer. Trams are a Rip Off. YLT. DTC.

I determine to try to track down some of the ghosts behind these messages. Given the illegality of the practice, it won't be easy. Graffiti writers don't leave their contact details pegged to the bottom of each piece. I, however, begin putting notes around town, mask-taped over the original graffiti, asking the authors to get in touch. Weeks pass and there are no answers. How even to begin to trace these phantoms?

Police constable Graham Belfall of Leith police - who is responsible for investigating graffiti in the area - seems a good starting point. He maintains a photographic database of local graffiti. The crime is under-reported, he says, but rarely without victims. He and his unit adopt the "broken windows" approach to the subject: that if you allow small elements of disorder to accumulate, it fosters an environment in which larger crimes flourish.

"People will argue that what they do is not graffiti," said Belfall. "They'll argue it's art. We have asked graffiti writers what would happen if they had a space they could use with permission. Would they stop graffitiing other places illegally? They said that yes, they would use it but they would keep doing it illegally as well. Part of the thrill is the possibility of getting caught."

Belfall distinguishes between different types of graffiti. The "YLT" logos daubed by the Young Leith Team, he points out, are not in the same category as the OE Gang tags. The latter's authors are involved in graffiti "culture", whereas YLT are not. "YLT is just what a lot of the youth in Leith know themselves as. They're just there, they've got a pen in their pocket." For Belfall, the graffitiists to catch are those that are involved in the culture as they are the most prolific. Indeed for many of them being "up" (having one's tag in many places) and going "all city" is the aim. Belfall recalls how one tagger he arrested was "mostly just disappointed he couldn't use his tag any more. He'd spent two years building up that identity among his peer group. He could go out on a night and write that over 100 times across the city".

Many of those involved in the culture of "tagging" (spray-painting your signature) are school age. They are mostly middle-class and they are generally male. They are known to hang out at the legal, council-provided, graffiti boards behind the Festival Theatre in Edinburgh. As one graffiti writer tells me: "The police know exactly who they are because they all sit about there with their bags full of spray cans. But if they don't catch them doing anything illegal there's nothing they can do."

Not far from these boards, I meet a small crowd of young adults. Most seem reluctant to talk, but the youngest comes over for a chat. "Kids start at about 11 or 12 years old. It's a lot to do with the people you hang with. Tagging is either about making territory or just saying, we were here'," he says.

Between here and his home in Pilton, the streets are littered with signs that, for him, tell a story. "I look at the different tags. Who was here? How long ago? You can tell that from how faded the paint is." The others join in the conversation. One is a former member of the Young Leith Team. What is his territory now? "All Edinburgh." What does it feel like when he does graffiti? "Like I'm creating great artwork."

I am beginning to think that I need a guide to this culture, someone who can educate me on how it works. And eventually, I find one on the internet, through a website on which many of the Scottish graffiti writers exchange chat and "beef" (complain). We arrange to meet in Edinburgh city centre.

John, a casually-smart looking student, is nothing like my image of a graffiti artist. Only the fingernails, rimmed with black paint, give him away. He has agreed to be interviewed because: "I want people to know the extent of the graffiti art that's going on away from their eyes, to change people's perception." He scans the wall opposite and points to the hoops, swirls and scrawls. "I know every single one of these guys," he says. "You can see where people have been. You start to read the streets."

John objects to the classification of graffiti art as vandalism. "I hate being ostracised from an audience who, when I show them our productions, are blown away. What people don't understand is that graffiti artists are the highest of critics of aesthetics. We want to create stuff that's good."

His "art" has earned him a criminal record. "I was put in a cell," he tells me. "I've got a problem with putting people in cells. It's fair enough in some cases, but for writing on a wall?"

John first started writing on walls at 13. One of his first tags involved spraying someone else's name around town. Now, the scope of his creations is much grander. His obsession with his craft has caused friction within his family. "If I show my dad my stuff he just looks right through it. He sees it as that stuff that gets his son into trouble. Graffiti is a hard graft. Everything's against you and people are really putting their jobs and lives at risk. A few of my friends' mothers are stressing out because they've got impending trials."

John talks about graffiti as a social movement. He evangelises. He describes how he can be sitting at home with nothing to do, then think: "Oh wait, I've got pens and paint. I can go out and have mad experiences just with paint." At times, he talks as though he thinks graffiti can change the world. Does he? "There are so many armchair revolutionaries and I feel like graffiti is this one way to actually physically have an impact right now."

Back home in Leith, I find myself reading the streets, tracking the movements of OHKS, DEBTS and the OE gang, whose tags appear along the walk. OE is everywhere: on the door of someone's house, on the wall of an empty public building, on the window of a telephone box, hidden up alleys and in the shadows of doorways. There aren't many big graffiti works along this road. The few I find are hidden from the street in the Lothian Regional Transport bus depot which, when I visit, is in the process of being demolished. From the pavement outside, through the railings, can be seen two large pieces. One is a legal work, created as part of the Leith Festival last year, by a Polish graffiti artist known as Lukasz, who works as a graphic designer and legal spray-gun for hire.

I meet Lukasz in a café in Leith. He tells me that he began his graffiti career aged 13, before he even knew the word for what he was doing. He had been out cycling with a friend who suggested that they went down to a wall in the woods with two spray cans. For Lukasz, Edinburgh, with its zero-tolerance approach to graffiti, is not a good place to be an artist of this kind. He would be better off back home in Wroclaw where graffiti is tolerated in certain places and celebrated in the city's annual arts festival. Still, he appears to like Leith. His bus depot piece - which features a line-up of faces of different nationalities - is meant to express the fact that you could meet almost anyone here. "Graffiti itself isn't bad," he says, "it's just where some people do it that's bad."

If any particular graffiti has dominated Leith Walk over recent months, it is the series that includes "Dante called her Beatrice". There are many of them scattered up the walk, all in the same style of lettering: "Lovers sleep alone", a lyric fragment from a song by the band Low; Friedrich Nietzsche's "All joy wants deep, deep eternity". And then there is the troubling: "Don't want to be alone in case those things come around again."

I am curious to find out what this is about. It seems to me to be in the tradition of the Situationist International, who in 1968 graffitied similar slogans across Paris, including: "Live without dead time." "Beneath the paving stones - the beach!" In recent years, Situationist strategies have become central to an anti-consumerist movement known as culture-jamming. A form of this was seen recently on the billboards of Leith Walk. Over an advertisement for shopping at Ocean Terminal were painted the words: "Be bad. Buy nothing new this Christmas."

The Dante Called Her Beatrice series does not seem to have an obvious anti-consumer message. Nor have the writers targeted big corporations or billboards. Rather, their messages are dotted along the broad, predominantly non-corporate artery of Leith Walk, on the shutters and walls of small businesses: a tanning salon, a hardware shop, a catering company. What is their point?

An answer, of sorts, emerges, when I finally receive a response to one of the notes I taped on a wall beside someone's graffiti. An email appears in my inbox, addressed from a group called the Safe Word Collective. "The motivation for that night's work," it declares, "came from a deep emotional unsettlement regarding a personal situation with more universal implications. We know what we did was illegal but the phrases used were a serious work of art to remind the public that the spirit will find a way to try to express itself regardless of the horrors and mediocrity and general soullessness which we are subjected to in this society on a fairly relentless basis. As I sit and type to you I've felt like crying two or three times."

This emailer, let us call him Dante, later replies to a series of questions. His group was founded 10 years ago, in an upstairs room in Cockburn Street. There are five members, four males and one female, "artists, musicians, writers, philosophers, some have normal jobs, some are signed off sick". Dante was one of the initial five, who "have all gone on to work and live according to our choosing. As time goes on we encounter other individuals who may become part of our drive and ideology".

What is their ideology? From reading their graffiti it is not clear. Dante writes: "We have to transcend the political, because it's become a hypnotic formula. We vote for the new guys, they bomb some country. Then we vote for the new guys, they bomb some country." There is much talk in his email of Eastern mysticism.

"There do exist certain techniques," he writes, "which when successful can reveal to human consciousness the great reality' which solves all." Meditation, he believes, is one of these.

I ask him about the "horrors and mediocrity and general soullessness" he mentioned in his first email. The news, he replies, was a starting point. "Billy Connolly once talked of compassion fatigue' caused by people being worn down by the relentlessness of various African troubles. I know what he meant. But how many of us who are not high-level Buddhists can respond daily with a fresh heart to all the problems of the world?"

And what, I wonder, is the personal situation he described in that first email, when he talked of how one of the group had found "a beauty begging on the streets"; a beauty with a history of sexual abuse, alcoholism, prostitution and heroin addiction? The Safe Word member had helped her to go through withdrawal but she had ended up back on the drug. It was the age-old tale of a broken romance.

The debate over whether graffiti is destructive or creative, is one I have tried not to labour in this article. It can't, however, go unmentioned. Having talked to many people in the Leith area about their responses to the range of graffiti, it is clear that most have their own hierarchy of acceptability. One woman tells me she finds the Safe Word graffiti invigorating, but dislikes the tags. Meanwhile, the owners of the daubed shops are displeased. "I've had to paint over my shutters three or four times," says the owner of Home Essentials. "It's really antisocial behaviour."

Those involved in the graffiti culture object to being called vandals, yet, at the same time, recognise that part of the pursuit's appeal is the illicit thrill. In researching this piece, I have listened to many people tell me that graffiti is an art. I get a chance to see that art in action when a practitioner gives me a demonstration on a wall at Glasgow School of Art. In large sweeps, he throws wisps of lime green spray across a black backdrop. This, he says, is his unique "ghost" style. The letters of his tag are almost indecipherable among the leafy fronds. Like some savage jungle in the mind of Joseph Conrad's Kurtz, it fills up the space between the ears and face created by his friend, an art student at Dundee's Duncan of Jordanstone College of Art. Here we have art: but is it graffiti?

Graffiti is by nature ephemeral. It comes and goes. In recent weeks, most of the Safe Word collective's messages have disappeared, replaced, in one day, by painted blank spaces. I call Graham Belfall to find out why it has all disappeared in such a co-ordinated way. Too many people have remarked upon it, he says. "To leave it up would just be to glamorise it."

A few days later, on a frosted winter day at the back of the former Queen Margaret University campus backing onto the Links, I watch as three of Edinburgh City Council's graffiti removal specialists erase a similar piece of "art". The paint is old and the symbols have clearly been there for years: it almost seems like a piece of local archaeology. The current squad, I am told, costs £350,000 a year. To do a complete clean of the city and create a blank slate would require four times that.

I began this investigation hoping to find out who had created these marks that appear fleetingly across our cities. I also wanted to know why. One artist I talk to suggests that graffiti writers often feel that "no-one is really interested in them". Many of them are "quiet" people, who are "yearning for something".

It seems certain, however, that there is no single answer to the question. Many different people graffiti for as many different reasons. Just look at the writings on the walls and that much is clear.

Some names in this article have been changed