Dedicated teacher Leonora Rustamova wrote a book to engage five teenage rebels in her class. But after it went up on a website she was dismissed, a decision that was upheld at a tribunal

For the five teenage "unteachables" in the class, sitting still was a challenge, never mind reading. But when their teacher, Leonora Rustamova, began to write her own stories, based on them and a fictional account of their lives, they were gripped. She wrote what quickly became a book in her own time, at weekends and on holidays, and promised to read them a chapter every Friday afternoon if they got through a week without any of them being excluded.

The work "Miss Rusty" was doing to engage troubled and school-phobic 16-year-olds first gained her a promotion. Then dismissal. After 11 years as a teacher at Calder high school in Mytholmroyd, West Yorkshire, Rustamova was sacked when the book was made available on the internet, a decision upheld by an industrial tribunal in Leeds that threw out her claim for unfair dismissal by a majority decision of two to one.

"It was baffling, utterly baffling. I still feel as though I am in some kind of dual reality," she told the Observer. As a leaving present for her pupils, and with the approval of the headteacher, Rustamova, 40, had several copies of the book, Stop! Don't Read This!, printed, using an online publishing website. The boys and their families were delighted; one parent told her it was the first book her son had read to the end.

"It boosted their self-esteem; it engaged them. We were having conversations and discussions," said Rustamova. "For a group of boys like this, that was incredible. I thought it would be a lovely gesture to have it printed for when they left school."

The school's headteacher, Stephen Ball, who had at first described the project as a "triumph", wrote her a note after reading the first four chapters that stated: "You've done a superb job with this. Let me know if I can help." He told her he was extremely pleased with the work she had done in interesting alienated and difficult teenagers in literacy.

Rustamova's husband, Denis, had used a publishing website to have the book electronically formatted and for several months Stop! Don't Read This was freely available as a download. It was that availability that led Ball to call an unsuspecting Rustamova into his office in January 2008, formally suspend her and have her escorted from the building.

"I had no idea about the internet website so I rang my husband to get him to get it taken down and I just sat in the car park staring at the school. In all the time I had been at the school no teacher had been suspended. I was just dazed," she said. "I thought the headteacher would smooth it all over with whoever had made the complaint and things would be back to normal."

But within months suspension had been turned into dismissal. Rustamova had lost her job, her career, and, during the investigation into her conduct, she was banned from talking to anyone from the school or its community, which included many of her friends.

"It feels so insane, this draconian reality that you are not allowed to speak to anyone within your own community, and I was always quite involved in my community – I still am, so to disappear from it like that, especially in a small town, it was very difficult not to worry there was going to be a bit of a witch-hunt."

Stop! Don't Read This! tackled some of the themes in the boys' lives – drugs, truancy, crime – and touched briefly on sexuality, describing an openly gay teenager as being as handsome as a Mr Gay UK finalist. It used the boys' real first names and their nickname "the commie boys". It named the school, although the rest of the content was fictional. The 96-page story ends with the boys all coming good and being praised by the police as "heroes".

"They were a really difficult-to-reach group: spirited, very intimidating to teach at first. We were all struggling to find a way of getting through to them and most of the time they were getting excluded. These were the kind of kids who really are cynical about education because they have never been engaged by it," said Rustamova.

When it became clear what she had been trying to do, the community was split by what happened to "Miss Rusty". Pupils at Calder high organised a protest and a campaign against the decision to sack her, her "commie boys" defended her on radio and in the local newspaper, while other teachers also came to her defence. The families of the five boys, who had since left the school, all backed her.

But the head, the governors and the local authority were deeply concerned about the appropriateness of Rustamova's actions and a disciplinary hearing ended with her dismissal in May 2009 for "reckless disregard for confidentiality and child safeguarding issues". Now that her action against unfair dismissal has also failed, Rustamova has to decide whether or not to appeal. "I am split," she said. "On the one hand I think, 'This isn't fair and I've come this far in the fight'; on the other hand, I have lived with this now for two years and it's very draining. I'm not one to get bitter and I do want to move forward."

Rustamova, a mother-of-one, still has to go before the General Teaching Council, a prospect she finds frightening. "They have the power to strike you off so it's terrifying, although with my baggage it will be difficult for me to get a job in teaching anyway," she said. "I loved my job, I loved that school. I miss it terribly. So this is hard."

Rustamova has lost more than her job: her marriage did not survive the strain. "My husband felt terrible for being responsible for the thing getting on the internet in the first place, so that was a hard mistake for him to live with and we disagreed very much about how I should deal with it," she said.

Of the denunciation that eventually brought her down, Rustamova said she had no idea who was responsible. But she has her suspicions about why her teaching methods might not have gone down well with everyone.

"It was an internal complaint and I don't know to this day who made it, but people say when you work in a school that you have to understand there is a Star Wars complex – people are always saying, 'There's a dark side operating!'

"I always had a child-centred approach and I often took the child's side if I thought they hadn't been able to explain themselves very well or been understood. A lot of people don't like that. But what was validating was the support of the kids; that was amazing. To this day it amazes me, I was getting little notes and even a squashed piece of child's birthday cake arrived one day.

"If I had harmed one child in any way at all I would never have forgiven myself; I would have sacked myself. But all I see is five fantastic young people who learned from their experiences, who have given their consent to that book being properly published and who are proud of what they achieved. And I am proud of them."

A local book company, Blue Moose, is to publish Stop! Don't Read This!, with proceeds going towards community projects. Rustamova's "commie boys", who had once been consigned to the educational scrapheap, have defied expectations and all gone on to further education and employment.

"We keep in touch and they like to joke that I spent so much time getting them to avoid the dole queue and now it's me that's on it, not them," she said. "I can't regret the book because of the effect it had on the students. I regret the mistake that allowed the book to end up on the website briefly. I regret my career coming crashing down."