When Alex Goodenough was 13, his English teacher asked his class to write the first chapter of a novel. Alex began writing his, and after chapter one he thought he might as well carry on. He kept writing and writing - about space-faring aliens killing each other - and when the day came to submit his work, he handed in 97,000 words. An entire novel.

"I noticed it was bigger than anyone else's," he says today. He thought the teacher would like it. "I judge books by how many aliens get shot - and everyone died in the end." Instead, he got "a thinly veiled comment about how important it is to wrap things up nicely - to write only what you can write in the duration of a Sats exam."

Alex had always been out of sync. At six months he was talking; by 14 months he was constructing full sentences. He began studying German at 13, sat his GCSE at 14 and got an A; by 15 he had four more GCSEs - he and his mother were already planning his Cambridge application. But at 16 his local school flatly refused to give him a place in the sixth form. Alex ended up teaching himself from textbooks at home, isolated, nocturnal, seldom leaving the house. "It was just the word 'Asperger's'," his mother Jan says. "Once they heard 'Asperger's', they didn't want to know."

When I arrive at their home in Bishop's Stortford, Hertfordshire, Alex is playing on his Xbox. The first impression is of a typically awkward teenage boy, monosyllabic and shy, but no more so than many 17-year-olds. It's only when he fails to make eye contact, and withdraws into himself like a computer shutting down, that the difference becomes discernible. He says nothing unprompted, and answers questions with an air of literal-minded detachment that is unnerving and oddly touching.

His mother looks like a photo negative of her son - fair, articulate, bustling with smiles. She has the intense, slightly strained energy of a tireless campaigner, but shows nothing but tender affection towards her son.

Asperger's is an autistic spectrum disorder, and while children with the syndrome often have strong cognitive development, they can be socially inhibited, have trouble empathising and display unusual obsessions and verbal tics - repeating catchphrases or jokes, for instance. Jan had known from very early on that her son was unusual, but it was some years before his diagnosis.

"I didn't have a name for it," she says, "but I knew from when he was tiny. It was quite bizarre; it was like having a little old man about the place. He needed so much mental stimulation; the phrase 'pushy parent' is the opposite of what it would be. When he was three, I'd say, 'Oh, let's go and play in the park.' And he'd say, 'No, teach me from the books.' There was this desire to achieve encyclopedic knowledge about absolutely everything. Dinosaurs to start with."

I ask Alex if he can remember the dinosaur phase. "I had a little book with dinosaurs I used to read every day, and I entered a competition at school about drawing dinosaurs, and I won, and I wanted a dinosaur, but they only gave me a picture of one in a frame. And I threw a tantrum."

"That's right!" His mother rolls her eyes; as she and I laugh, Alex is impassive, but I get the feeling he is pleased to have made us smile. It's the first hint of something more knowingly playful, and I begin to see what his mother means when she says Asperger's can be more complex than the stereotypes suggest. "If there was a cure for Asperger's," she says, "I wouldn't want it. Al's just himself."

When Alex and his sister, Imogen, were six and four, their father left, and Jan has since brought them up alone. They attended a private preparatory school in Cambridge, where they used to live, and were very happy, but Jan couldn't afford secondary school fees, so when Alex turned 13 the children enrolled at a local state school, Hockerill, in Bishop's Stortford.

Academically, Alex shone. And socially, too, he got by for the first year. Other kids soon realised how clever he was - "And it made them like me when I did their homework." But by the age of 14, he says, "I just stopped having friends, and started going to sit in the library by myself every break time." Can he remember why they stopped being his friends? "Um ... Dunno, really." He looks at his mum and sees her expression. "What?"

"Well, they beat you to a pulp!" she exclaims.

"Well, yeah," he agrees softly. "And that, yeah."

Can he remember what provoked the fight? "Probably me. It's always me." He says it without self-pity. "He's been bullied by other kids ever since nursery," his mother says quietly.

In the two years Alex spent at Hockerill, he never once visited a schoolfriend's house. "When I left my prep school, I don't know why, but I didn't bother to get anyone's phone number or email address to keep in touch. I never thought of it. This is going to sound bad," he says, "but I just forgot about them." The normal adolescent obsession with the dramas of friendship must have baffled him, I say. "Generally, if everyone else is doing something, then I think, 'Why aren't I doing that thing?' And if I can see a benefit in doing it, I'll do it. But I couldn't see any benefit."

Alex's solution was to stop going to school. By year 10 he was working on his third novel - a sci-fi fantasy - and would sit up all night writing, sleeping during the day and waking at around 3pm, just as his mother and sister were arriving home. Gradually, he stopped leaving the house. "I was comfortable there. I was safe. To be honest, I quite liked being in my own little world."

"He was a mess," his mother says quietly.

For years, Jan had wondered if her son might have Asperger's - around one in 100 Britons is on the autistic spectrum. But, like most people, she had only a limited understanding of the condition, and his facility for language seemed to rule it out. By now, she was desperate; a doctor had diagnosed her son with clinical depression, but Jan suspected this was a symptom, not a cause, of his problems, so she paid for Alex to see a psychiatrist and an educational psychologist. "It was a fuming, gritted-teeth Al," she smiles ruefully, "who went to see them."

Alex's objection was simple: "I don't think I've got a disability. I like being me."

The diagnosis of Asperger's felt, he says, "like a label. I felt like a jam jar." You can see what he means, for the word conjures images of The Curious Incident Of The Dog In The Night-Time, Mark Haddon's bestselling novel about a boy with Asperger's that has come, for most people, to represent the definitive account of the condition. But when Jan shows me Alex's Facebook page, I'm amazed; on screen is someone almost unrecognisable - witty, acute, confident. "I like it on Facebook," Alex says simply. "It's removed, it's detached. It's just me talking to one other person at a time, so I'm OK."

Though Alex shares many of the classic Asperger's symptoms - social awkwardness, alarm at noise and disorder - his interest in literature confounds the stereotype of the science boffin, and his sense of humour is even more of a surprise. When he says, "As soon as you say Asperger's, people think he's going to have glasses - which I do - he's going to be pretty intelligent and he's not going to talk much," he pauses one beat before setting up his punchline: "And he's going to play chess."

Does he play chess? "No, I play guitar."

The diagnosis did solve one problem - it got Alex into another school. By then, Jan was teaching at Helena Romanes school, a "bog-standard comprehensive, but one of the most inclusive schools I've ever come across." The Goodenoughs lived outside the catchment area, having moved to Bishop's Stortford, but because Alex was now classified as having special educational needs, he was given a place.

Alex's education finally seemed to be working. The school arranged for him to take some of his lessons by himself in the library, using textbooks; he could have his lunch at a different time, to avoid the uproar of the canteen, and "whenever things were getting overwhelming for Al, he could retreat to my room". He took two GCSEs in English and two in maths a year early, and in year 11 the school allowed him to begin studying for four AS levels - English literature, philosophy, general studies and maths - while completing six more GCSEs. "He was allowed this individual, hybrid year timetable, and that's all he needed," his mother says wistfully.

Had she been able to continue teaching there, that would probably have been the end of the matter. But, Jan says, a perception of favouritism had formed among some of her colleagues. "Al was being treated like something really special, and allowed to run his own show. Other teachers who'd wanted their kids in the school hadn't been able to do it." The idea that Alex could qualify as special needs when he was clearly the most able child in the school struck some colleagues as ludicrous, and the hostility that Jan says she felt became intolerable. She took a new job and, once again, Alex had to find a new school.

Jan thought it would be easy; the Hertfordshire & Essex High school was close by, and who would say no to a straight-A student? But the school refused even to send Alex an application form.

Over the course of several months, Jan was told three times that the sixth form was full - it wasn't. She was told the school could not accept Alex because the staff didn't know him well enough to write his Ucas reference - even though Ucas does not insist upon a school reference for university applications. She was told she'd applied too late - even though the school later admitted this wasn't the case. And she was told Alex wasn't wanted because his condition meant he couldn't guarantee regular full-time attendance.

"I think," Jan says, "because of the prejudices and preconceptions about Asperger's, plus their disbelief that any teenager could be naturally motivated to learn, when I described Al they thought I was lying." So Alex spent the second year of his A-levels back in his room again, alone, teaching himself maths, further maths, further maths additional and physics from textbooks. Before long, he was nocturnal again, refusing to leave the house, so Jan took the school to a special educational needs and disability tribunal.

According to the National Autistic Society, 25% of children with autism have been excluded from school at least once. More tribunal cases concern autism than any other special educational need. In truth, accommodating children such as Alex, who almost invariably require some special arrangements, must be a challenge for any busy mainstream school. But under the Disability Discrimination Act, schools have an obligation to make "reasonable adjustments" for a disability.

Oliver Hyams, the barrister who represented the Goodenoughs, warned Jan that there was "no money to be won"; she would have to pay her own costs, and even if she won there would be no compensation. Nor was there any guarantee of success. "This question of 'reasonable adjustments'," Hyams says drily, "has been the subject of much litigation."

But the Goodenoughs won their case. The tribunal found Alex's education was "probably adversely affected", and ordered the school to apologise to Alex for treating him less favourably, "for a reason related to his disability". In a statement to the press, the school said it was "very sorry that a misunderstanding arose", adding that it "was very much a mutual confusion in failing to arrive at a clear understanding on the part of the school as to what Mrs Goodenough was seeking for her son. The tribunal also acknowledged that the school is alive to the issue of discrimination."

The chair of governors, David Redfern, seems weary and dismayed by the whole saga. "This is not the nasty and the good," he says, choosing his words with care. "This is a total misunderstanding. My instinct has been to let it rest and say nothing, because I don't think it helps anyone - least of all Alex - to inflame it any further. But this is very upsetting for the school, because there is absolutely no issue of discrimination here."

The school hadn't even realised Alex had a disability until the lawyers got involved, he insists. "He would have been welcomed with open arms. But we never understood that, and it just blew up out of all proportion before we knew where we were." He points out that the tribunal did not - as it could have - order staff to undergo any training in discrimination issues. "It didn't because we don't need it."

Like most legal disputes, it became a quagmire of claim and counterclaim. But by then Alex had sat most of his A-levels from home, and the tribunal had cost Jan £7,500 - a moral victory she feels was worth it, though Alex can't quite see it.

"What he can't understand," Jan says, "is I'm taking issue with the system. I didn't think it should be possible for someone to do damage to another human being, and not have to pay some sort of compensation. I find it appalling that special needs people don't have the same rights as other people. Someone can mess up their lives, and all they're due is a letter of apology."

What Alex also now has - much more importantly to him - is an offer of a place from Trinity College, Cambridge, to study engineering. With three A-levels at A grade already, and three AS levels, he was offered the place on condition that he sit his practical exams in physics - for which his mother has enrolled him at a fee-paying school, funded by selling part of their back garden. While he was there, he thought he might as well take chemistry and economics, too. All being well, by this summer he will have six A-levels - and in October he will become a Cambridge fresher.

What are his hopes for the future? "I wouldn't mind Jeremy Clarkson's job, but he'll probably still be alive. It's a nice job. It's about engineering."

And when he pictures life at university, what does he see? "Umm..." he says. "Lectures. Random chats. Robots. Drinking, possibly."

"But you don't drink!" his mother laughs.

For a second, Alex looks thrown. "I'll learn how," he says. "I'll teach myself."

• Information about Asperger's is available from autism.org.uk.