A controversial trial of forcing voters to show ID could have been illegal because it was incorrectly imposed by ministerial diktat rather than through parliament, senior barristers have said.

The legal opinion by two barristers from Blackstone, a leading chambers in London, concluded that ministers acted beyond the scope of the law in ordering the trial of compulsory voter ID in five boroughs in England at last month’s local elections.

If upheld by a formal court challenge, the view could prevent any further trials or a national rollout of voter ID taking place without the formal consent of parliament, which could prove difficult given objections to the idea.

The scheme, in which people in Bromley, Woking, Gosport, Watford and Swindon were forced to show varying types of ID before being allowed to vote, prompted concern from charities, who warned it might put off more vulnerable groups such as elderly people and the homeless.

It was also criticised as a solution in search of a problem after it emerged that none of the trial boroughs had reported any cases of voter impersonation in recent years.

The opinion by Antony Peto QC, joint head of Blackstone, and fellow barrister Natasha Simonsen said it appeared the Cabinet Office had been wrong to order the trial through secondary legislation, sometimes known as Henry VIII powers, whereby laws can be amended by directive without a vote in parliament.

Their paper, seen by the Electoral Reform Society, said that while the relevant law, the Representation of the People Act 2000, does have provision for changes to be made to voting methods by secondary legislation, it was worded to indicate this should only involve ways to make voting easier, rather than making it potentially more difficult.

The law, the barristers argued, talks about how trials could be assessed by seeing whether turnout was higher than previous local elections.

“Schemes that restrict or discourage voting, or that inhibit voters, are not within the meaning of the section,” they said. As such the scheme was likely to be ultra vires, or beyond the scope of the law.

Labour, which opposed the trial, said the legal opinion showed the idea should now be abandoned. Cat Smith, the shadow minister for voter engagement, said: “After this intervention, it is impossible for the government to justify its undemocratic and unlawful plans.”

While one early estimate suggested up to 4,000 people might have been turned away from voting booths, official figures show the actual figure was significantly lower.

However, the legal opinion noted, there appeared to be no way to assess how many people were put off from even going to the polling station due to the ID requirement in five English boroughs.

The Cabinet Office has not said how it would respond to the trial, but has hailed it a success, meaning it seems likely the idea could be extended across England at future elections.

However, if the Blackstone opinion is upheld in a court, this would now need a formal amendment to the law and a vote in parliament.

The Cabinet Office said it disagreed with the view. A spokeswoman said: “The powers to make the pilot scheme orders are contained in section 10 of the Representation of the People Act 2000 which enable changes to be made to the rules regarding the conduct of elections. The act was fully debated and passed by parliament.”