Tony Blair personally intervened yesterday to save the government's mental capacity bill, striking a last-minute deal with the Catholic church by promising that the bill will not allow euthanasia by the back door.

Mr Blair held telephone conversations with the Archbishop of Westminster, Cardinal Cormac Murphy-O'Connor, while Lord Falconer, the lord chancellor, held parallel talks with Peter Smith, the Catholic Archbishop of Cardiff.

As a result, the government offered two concessions: that "living wills" be written and witnessed and that doctors or the patient's agents should not be motivated to bring about the patient's death.

Frantic discussions preceded the Commons vote to head off a backbench Labour rebellion, largely centring on Catholic MPs.

News of this belated bartering was then rushed to Labour MPs, whittling the Labour rebellion down to 34 MPs with a further 100 abstentions.

The reduced rebellion meant the Commons voted by 297 to 203 not to back an amendment tabled by the former Conservative leader, Iain Duncan Smith, preventing doctors doing anything that might intentionally cause the death of a patient.

In an exchange of letters, disclosed only 30 minutes before MPs were preparing to vote on the amendment, Lord Falconer gave written undertakings to the Catholic church that it would not be possible for anyone "to withdraw treatment where the motive is to kill, as opposed to relieving or preventing suffering".

The law, he said, would also allow doctors to cease treatment "where the patient is in an irreversible coma".

He added any such decision at this stage "would have to be in the patient's best interest".

The government insisted this clarification only made explicit something that was implicit in the bill.

Ministers also insisted it would not undermine the ruling in the landmark case of Tony Bland, the football fan who ended up in a permanent vegetative state after the Hillsborough disaster. The ruling had cleared the way for the withdrawal of Mr Bland's artificial feeding tubes by declaring them "medical treatment".

In response to Lord Falconer, the Archbishop of Cardiff wrote back welcoming the clarification, even if his own letter contained an interpretation on the hasty agreement that was not then fully supported by ministers.

The government's chaotic handling of the issue brought a rare rebuke from the deputy speaker, Michael Lord, who said it was quite wrong for the government to circulate the Falconer letter so late, and then to restrict the distribution to Labour MPs.

He repeatedly interrupted the constitutional affairs minister, David Lammy, for failing to spell out the concessions and "failing to organise things as they ought to be organised".

Mr Lammy, largely ignorant of the details of the negotiations or the letters, appeared to flounder in the face of both demands and then pleas from MPs to see copies of the exchange of letters.

The normally loyal Sir Gerald Kaufman, contemptuous of Mr Lammy's performance, was still angry last night that Labour MPs had not been given a free vote on what they regarded as a conscience issue, unlike the Conservative and Liberal Democrat MPs.

Other frustrated Labour MPs said the position would only be clarified when the bill passed to the Lords.