By Robert Pigott
BBC religious affairs correspondent
It was a close-run thing, but Anglican clergy managed to defeat a plan for new "heresy courts" in the Church of England.
Dr Rowan Williams said the debate was not about "sex and surplices"
The tribunals could have suspended or even defrocked priests or bishops who promoted beliefs at odds with the Church's teaching.
At the Church's Synod meeting in York, the whole thing came down to just four votes.
Lay members of the Synod voted for the new courts by a margin of two to one, and the bishops were heavily in favour. Only the clergy were undecided.
There is widespread dissatisfaction with the existing system of courts.
They are considered ineffective as well as expensive - with the result that clergy who go off-message are rarely brought before them.
The case for a revamped system was made by a series of - mostly traditionalist - Synod members.
Some stressed the need for the Church to establish and enforce boundaries, some sort of limits, so it was clear that it stood for something.
The Bishop of Rochester, Michael Nazir-Ali, said a "trend towards permissiveness" needed to be addressed to prevent a "doctrinal free-for-all".
Bishop Peter Forster said some sanction was needed for rebel clergy
He may have been referring to clergy who favour a reinterpretation of the Bible in line with modern experience, leading them to support the ordination of gay clergy and the blessing of same-sex relationships.
The proposal for the "heresy courts" was that they should investigate clergy who "professed... or promoted beliefs incompatible with the Church's doctrine".
Liberal clergy - including those who want the Church to be more tolerant of homosexuality - were worried that the courts could be used as a stick to beat them.
But traditionalists could also have fallen foul of the tribunals, for instance over their reluctance to wear clerical clothes for common services, or to baptise very young children.
The Archbishop of Canterbury, Dr Rowan Williams, said anyone observing the debate so far would think it was all about "sex and surplices".
Dr Williams said it was really about making the Church more credible.
He said some beliefs were simply incompatible with Anglicanism - support for apartheid, for example.
The Bishop of Chester, Peter Forster, said there was no intention of dragging more clergy into conformity to a strict doctrinal line, but it was necessary to have some sanction against the few who defy the rules.
It was only a last resort. But what else, he asked, could be done with a vicar who said he no longer believed in God but thought he could still do the job perfectly well and rather liked living in the vicarage?
Others - including the Dean of Oxford, Christopher Lewis - felt discussion was better than law as a way of resolving disputes.
Many disputes, he said, were better left unresolved.
He, like many on the liberal wing of the Church, stressed the need for it to stay in touch with modern thought - to continue to question its teaching, to avoid freezing it, for fear of becoming irrelevant.
"The Church will wither away if it isn't exploratory," he warned. "It will stagnate."
In the end, the measure failed but only because all three houses of the Synod - the bishops, clergy and lay people - have to agree, and the clergy voted against by four votes.
There was something very Anglican about the whole thing.
One avowedly conservative member, the Rev Stephen Trott of the Peterborough diocese, said he treasured the "breadth and splendour" of the Church of England.
Every effort to enforce the strict letter of the law had proved disastrous in the past.
An ability to turn a blind eye to unconformity may have helped preserve the Church's fragile unity for this long, and - at the last minute - given clergy pause for thought.