In the principal's office the air was still heavy with the reek of burning as workers tried to clean up the debris – wrecked files and crushed educational prizes that bore testament to the school's achievements. In the schoolyard lay the blackened remains of torched computers.

A week ago, a mob besieged Lahore's Farooqi Girls' School and set the classrooms ablaze after a young female teacher was accused of blasphemy. The teacher, who is Muslim, has gone into hiding – and the school's 77-year-old principal and founder has been arrested by police and charged with the same offence, a crime that in Pakistan carries the death penalty.

But the school, which offers an affordable, modern education to the daughters of ordinary families, is fighting back. And its female pupils, supported by their parents, have been at the forefront of the battle.

This week hundreds of youngsters have been arriving every morning and taking lessons in a makeshift classroom on carpets laid down in the street. "Education is to help us get a better life," said one 11-year-old.

The attack, weeks after Taliban gunmen shot the teenage activist Malala Yousafzai, has highlighted two issues: the struggle to educate children, especially girls, in a nation where more than five million youngsters do not go to school; and the power of religious conservatives and their alleged manipulation of blasphemy laws.

The incident, which caused an estimated £60,000 of damage, happened as the children were preparing to break for the Eid holiday. Officials said that homework given to a class of 11-year-olds by Arfa Iftikhar, 21, contained a line that insulted the prophet Mohammed. Scholars from a nearby religious school complained and Asim Farooqi, the principal of the girls' school, confronted the young teacher, who said she had made a terrible error while copying exercises.

It transpired that while copying exercises from the Pakistan Secondary School Grammar and Composition textbook, Ms Iftikhar had started with a piece on page 360 about the Koran and the prophet Mohammed. But rather than continuing to page 361 and completing the excerpt, she had skipped to page 362 and an exercise entitled "The Street Beggar", which claimed such people were "cheats".

The implied meaning of the two half-paragraphs was so painful that Inspector Azeem Manais, the police officer investigating the case, declined to read them out loud. He said police were trying to find out whether page 361 was missing from the teacher's copy of the book. Asked if he believed the teacher had made a genuine mistake, Mr Manais said: "Because she is in hiding it is too premature to say."

For several days, it appeared the issue would be peacefully resolved. Mr Farooqi spoke with the religious leaders and obtained a statement from Ms Iftikhar before firing her. The handwritten letter said: "I also pray to God that he should forgive me for this great sin of mine."

But then it appears someone translated the offending piece of homework into Urdu and distributed photocopies. On 30 October, a large crowd gathered outside the school and threatened staff. Mr Farooqi and other school officials, barricaded inside, were only able to escape the following morning, when police intervened. Later a crowd returned, broke in and ransacked the building and started fires.

Whether the protests were spontaneous remains unclear. Teachers suggested rival establishments were envious of the school and may have seized on the incident, though they offered no evidence.

The individual whose name appears as a complainant on the blasphemy charge filed with the police against the principal is Abdullah Saqib, who heads a mosque in Bilal Gunj, a different neighbourhood. He said by phone: "Now there is an investigation underway I will not be able to talk about this for a day or two."

School officials have sought to distance themselves from the teacher and have called for her to be punished, despite several of her colleagues saying they believed her mistake was genuine. The school even took out front-page advertisements in newspapers declaring: "Our school management and the owners have no link whatsoever with this dirty act."

Campaigners against Pakistan's blasphemy law say it is routinely used to settle disputes that have nothing to do with religion. People accused of the offence have been murdered before their case has reached the courts. And in January 2011 Salmaan Taseer, the former governor of Punjab province who supported reforming the law, was shot dead by his police bodyguard.

Several religious leaders have now ruled that the attack on Farooqi Girls' School was wrong. And this week Bilal Yaseen, an MP, visited the school and told the youngsters the matter had been settled. The children clapped.

The pupils of Farooqi Girls School said they were keen to get back in their building. "It's very sad. They destroyed our school," said Kanwal Tehseen, 11, who was in Ms Iftikhar's English class. Of her teacher, she added: "We liked her. We respected her."

Some girls were already thinking about careers as computer scientists or doctors. "It's easier for boys to go to school. Parents think that the boys are going to be responsible for supporting the family," said 15-year-old Fareeha Zaheer. "Basically our religion teaches that it is important for us to get educated. The mother is the first educator in the household."