The justice secretary, Chris Grayling, has suffered a defeat in a key House of Lords vote on his plans to curtail access to judicial review, which would have made it harder to challenge government decisions in court.

Peers voted by 247 to 181, a majority of 66, to ensure that the judges keep their discretion over whether they can hear judicial review applications after a warning from a former lord chief justice, Lord Woolf, that the alternative amounted to an ‘elective dictatorship’.

“It’s dangerous to go down the line of telling the judges what they have to do,” he told peers.

Peers who voted against the government included the former Conservative cabinet minister John Selwyn-Gummer, who sits as Lord Deben, the former Tory chancellor Lord Howe, and 17 Liberal Democrat peers, including the former party leader, Lord Steel, and Baroness Williams, who said they were very troubled by the proposals.

The key set of amendments restored judicial discretion to several elements of Grayling’s plans to curtail judicial review.

He has in the past said the reforms are needed to end unnecessary delays and curb the activities of “leftwing” campaigners who have used judicial review to frustrate government initiatives.

But peers were unimpressed when the justice minister, Lord Faulks, cited a six-month delay in the development of a supermarket as being a key reason why the reforms were necessary to prevent major projects being held up for months or even years.

He went on to accuse critics of mounting an “outright attack” on a government bill that had already been backed by MPs and said the reforms were needed because there had been a threefold increase in judicial review cases in recent years, up from 4,200 in 2000 to 15,600 in 2013.

He said that judicial review could be used to hold up official decisions even in “hopeless” cases.

Deben, the former Tory cabinet minister, reminded peers that while judicial review might be used by leftwing causes in Britain, in America the separation of powers was mainly used by rightwing organisations to challenge executive actions.

“It is unacceptable if we have a system whereby if the government has acted illegally it can’t be brought to account in the courts,” he said. “The British defence of freedom is judicial review.”

The Conservative justice secretary is likely to try to overturn the defeat when the criminal justice and courts bill returns to the House of Commons but the closer the election comes the less likely it is that it will be a foregone conclusion he will succeed.

The defeat in the House of Lords followed repeated warnings that Grayling’s restrictions on access to judicial review would have a “chilling effect” on those seeking justice.

The three main legal professions in England and Wales last week also condemned Ministry of Justice plans to prevent charities and non-governmental organisations from intervening in judicial review cases which contained matters of public interest.

Sadiq Khan, the shadow justice secretary, responding to the government defeat, said: “This is a humiliating slapdown for the government. These changes would have weakened judicial review, and would have placed the government above the law. This was a massive grab for power which is why Labour voted against. Judicial review is a crucial tool for the British people to hold to account the actions of those in positions of power and responsibility.

“If these plans had gone through it would have been a recipe for bad decision making allowing governments and ministers to get away with pushing through actions that were potentially unlawful.”

Grayling later suffered a second defeat. Peers voted 228 to 195, a majority of 33, over the issue of requiring applicants for judicial review to provide information on the financing of the application.

Lord Pannick, moving the amendment, said its aim was to ensure that a court had discretion rather than a duty in relation to information about funding.

But Faulks denied the bill removed judges’ discretion and insisted the government’s change was about ensuring greater transparency. He said the aim was to enable judges to have better information before exercising discretion to order costs and insisted this would have no “chilling” effect on applications.

The division list showed the amendment was also supported by four bishops, 157 Labour peers, 54 crossbenchers and 12 others. The government supporters were 131 Tories, 43 Lib Dems, five crossbenchers and two others.