Boris Johnson suffered a significant Commons rebellion on Tuesday when 33 Conservative MPs voted against the government in an effort to outlaw trade deals with countries committing genocide.

The amendment to the trade bill was initially proposed in the House of Lords and would have handed UK courts the power to determine what state actions would count as genocide and force the government to pull out of any trade deals.

MPs voted 319 to 308 to cancel the proposal, almost erasing Mr Johnson’s majority. The amendment was also supported by the opposition Labour and Liberal Democrat parties.

The rebels spanned both wings of the Conservative parliamentary party, including rightwing China hawks, who have been deeply critical of Beijing’s treatment of Uighur Muslims, and those from the left of the party taking a stance on human rights.

Greg Hands, the trade minister, told MPs that the genocide amendment would be an “unprecedented and unacceptable erosion” of parliament’s sovereignty, but pledged to work with the rebels to find a solution.

“To accept this specific amendment would allow the high court to frustrate, even revoke trade agreements entered into by the government and approved after parliamentary scrutiny,” he said.

Former Tory party leader Iain Duncan Smith supported the amendment, along with former ministers Damian Green and David Davis. Seven select committee chairs also joined the rebels, including foreign affairs committee chair Tom Tugendhat and defence committee chair Tobias Ellwood. Jeremy Hunt, the former Conservative foreign secretary, abstained on the vote.

Mr Duncan Smith, who led Tory efforts to pass the amendment, said that the campaign to outlaw trade deals with certain nations would continue when the legislation returned to the House of Commons.

He tweeted: “Today’s rebellion shows the govt can’t ignore calls to bring genocide cases before UK courts. We’ll continue to work on this amendment, considering all points MPs made today. I hope the House of Lords will ensure an improved amendment returns to the House of Commons.”

David Alton, the Liberal Democrat peer who instigated the amendment in the Lords, said “the fight does not end here” and peers would “continue to do all we can to ensure that Uighurs and other victims of alleged genocide have a route to justice through UK courts”.

The rebels’ cause was boosted by the declaration by US secretary of state Mike Pompeo that China had engaged in “crimes against humanity”. On his final day in office, he said: “I believe this genocide is ongoing and that we are witnessing the systematic attempt to destroy Uighurs by the Chinese party-state.”

Downing Street said that Mr Johnson was proud of the government's record in standing up for human rights in China, citing recent proposals to stop the use of forced labour in Xinjiang in British supply chains.

But Number 10 argued that Britain neither had a trade deal with China nor was it seeking one. “We recognise the strength of feeling. But we don’t support the amendment,” a spokesperson said.