The General Synod, the Church's legislative body, rejects legislation allowing the ordination of women bishops Reuters

The Church of England has been plunged into its gravest crisis in decades after legislation that would have allowed female clergy to become bishops, and swept away centuries of entrenched sexism, was rejected by just six votes.

In dramatic scenes at Church House in Westminster, a long-awaited measure that was the result of 12 tortuous years of debate and more than three decades of campaigning was defeated by lay members, prompting one bishop to warn that the established church risked becoming "a national embarrassment".

The legislation had needed a two-thirds majority in each of the three houses of the General Synod to pass, but, despite comfortably managing that in both the houses of bishops and clergy, it was dealt a fatal blow in the laity, where lay members voted 132 votes in favour and 74 against. If just six members of the laity had voted for instead of against, the measure would have been passed.

The result was a disappointment for campaigners who warned that the church's image in the eyes of parliament and the public had been severely damaged. It was also a bitter blow to Rowan Williams, the outgoing archbishop of Canterbury, whose time at Lambeth has been dominated by the issue and who had campaigned personally for a yes vote.

"Of course I hoped and prayed that this particular business would be at another stage before I left, and of course it is a personal sadness, a deep personal sadness, that that is not the case," he said .

The failure will also present a challenge to Justin Welby, the bishop of Durham, who takes over from Williams next year. In an impassioned personal plea before the vote, he had urged the synod to support the measure and to "finish the job" of women's ordination. Welby was "taking stock" on Tuesday night. The house of bishops, which voted 44 to 3 in favour of the reform with two abstentions, will meet for an emergency session to try to find a way to rescue the legislation.

If it fails, the synod will not be able to return to women bishops legislation for another three years, during which time supporters are likely to push for a more uncompromising single clause measure. The rejected legislation would have worked alongside a code of practice to ensure those opposed to women bishops – chiefly conservative evangelicals and traditional Anglo-Catholics – could have requested an alternative male bishop.

"We are deeply disappointed that the General Synod has made a decision so out of step with the will of the Church of England as a whole," said the Group for Rescinding the Act of Synod, which campaigns against these so-called flying bishops. "The synod's decision to reject the measure cuts right across what the vast majority of men and women in the Church of England long for and shows that our attempts at compromise have been ignored. It undermines the validity of the ministry of every ordained woman and sends out a negative message to all women everywhere."

Tony Baldry, the Conservative MP who is responsible for speaking for the synod in parliament, said it would be "extremely difficult if not impossible" for him to explain the church's current predicament to MPs. He has previously warned it would be difficult for him to defend the guaranteed place for bishops in the Lords.

While some have suggested the move could even call into question its status as the established church, Baldry said he thought the bigger risk was simple "disinterest". "I think the great danger for the church following this vote is that it will be increasingly seen as just like any other sect," he said.

A source close to the culture secretary, Maria Miller, who is also minister for women and equalities, said: "While this is a matter for the church, it's very disappointing. As we seek to help women fulfil their potential throughout society this ruling would suggest the church is at the very least behind the times." When the measure was put to the church's 44 dioceses earlier this year, 42 approved.

A ComRes poll in July found that 74% of respondents thought female clerics should be able to attain the highest reaches of the church. The bishop of Lincoln, Christopher Lowson, said the failed vote could make the church look even more outdated. "This is a very sad day indeed, not just for those of us who support the ministry of women, but for the future of the church, which might very well be gravely damaged by this," he said.

"The church has suffered a serious credibility problem while it worked on the legislation, and this is a setback that could cement the church's reputation as being outdated and out of touch."

The bishop of Chelmsford, Stephen Cottrell, said: "There's a risk the national church will become a national embarrassment."

For opponents of the measure the victory was a long-awaited sign of conservatives' power in the synod.

Rod Thomas, chair of the conservative Evangelical Reform group, said: "It was as close as we thought it would be. My overall conclusion is that it is very good news for the Church of England.

"We have avoided what could have been a disastrous mistake for our unity and witness. We can now sit down and talk through how the Bible helps us to move forward together. It was very interesting that the archbishop designate pledged himself to working positively with both sides and we want to respond to that by making ourselves completely available for discussion."

The Church of England said that, in all, 72.6% of synod members had backed the measure in the crucial vote, which came at the end of more than 100 passionate and moving speeches. But it was not enough to see it through. In the house of clergy the measure passed by 148 votes to 45. If six members of the laity had voted for instead of against, the measure would have received the two-thirds majority needed.