Labour MP Clive Lewis has gone against his party to vote against the controversial so-called “spy cops” bill.

The Norwich South MP said he had defied the Labour party whip “with a heavy heart” but argued the proposed legislation was “dangerous” and should be opposed.

The Covert Human Intelligence Bill would grant wide-ranging legal rights to undercover agents to commit crimes in the course of their work.

It would explicitly authorise police, the National Crime Agency, MI5 and other agencies that use informants or undercover agents to commit a specific crime as part of an operation.

However, the legislation stresses agencies must not breach the Human Rights Act, which requires the government to protect life.

In a post explaining the reasons for voting against at the third reading of the bill on Thursday, Mr Lewis said: “Whatever the alleged checks and balances in this bill, at its heart it breaks a fundamental element of natural British justice.

“That is that without a written constitution, without a Bill of Rights, we accept that ‘everyone is equal before the law’. It sounds silly to have to state this, and yet this is a principle that has been hard won by the people of this country over many centuries.

“And yet this bill undermines that principle. It basically allows a wide range of public and arms lengths bodies to award in effect ‘a license to kill’ – putting them out of the reach of the law we all are accountable to.”

Labour leader Sir Keir Starmer, a former director of public prosecutions, argued that although the legislation was flawed Labour should not vote it down because it is crucial to enable clandestine policing to continue.

But 34 of his MPs – led by Jeremy Corbyn, John McDonnell and Diane Abbott – voted against it on the grounds it is a breach of the rule of law.

Labour frontbenchers Margaret Greenwood, the shadow schools spokesperson, and shadow financial secretary to the treasury, Dan Carden, both resigned over the issue.

The bill passed its third reading by 313 votes to 98.