Fiona Hyslop, the Education Secretary, told The Herald she would move immediately to reduce the statutory maximum class size in P1 from 30 to 25.

The government is also considering longer-term legal changes, firstly to reduce class sizes to 25 in P2 and P3, and then to bring them down to 18.

The move, to be announced at the annual Scottish Learning Festival, in Glasgow, has been made to close a legal loophole that has undermined the government’s policy on class sizes.

The government promised to reduce class sizes in the first three years of primary to just 18, but progress has been limited -- partly because the current legal maximum is 30. That has meant local authorities have been unable to reduce class sizes in popular schools where parents can use placing request legislation to ensure entry for their children.

“We are going to introduce regulations to introduce a maximum class size of 25 in the first year of primary school from the start of the next school year to ensure we can drive forward with our class size reductions generally, as well as helping local authorities when they are facing legal challenges,” Ms Hyslop said.

“This is a short-term measure which will act as a stepping stone to stronger regulation of class sizes more generally. We are conscious that we may need to legislate for 18 at a later stage, bearing in mind the experience we have had with moving to 25.”

Ms Hyslop will also unveil plans for a wide-ranging review of the regulation of class sizes in all years of primary and secondary, in consultation with teaching unions and local authorities.

While the review will not pronounce on what class sizes are appropriate for different year groups, it will attempt to establish a single method for governing them.

“We will be establishing a review of class sizes to resolve the current situation, which is a dog’s breakfast of circulars, regulations, guidance and terms and conditions with anomalies and disparities,” Ms Hyslop added.

“What I also want to do, with a view to introducing primary legislation if needed, is to establish a system of class-size regulations that is coherent and consistent and which would be able to deliver further reductions to class sizes in future.”

The Education Secretary’s announcement is likely to receive a mixed reaction. Local authorities that have been hampered in their attempts to bring down class sizes are likely to welcome the legal change.

Teaching unions, which support smaller class sizes, will also see the reduction in the statutory maximum as a step in the right direction.

However, opposition will come from political opponents, who will argue that the change to 25 is an admission that the SNP’s manifesto pledge to reduce class sizes in P1-P3 to an 18-pupil maximum is dead in the water.

In particular, the Scottish Labour Party has repeatedly attacked the SNP over the slow progress towards the targets.

Rhona Brankin, the party’s education spokeswoman, said: “There was no mention of legislation on class sizes in the recent programme for government, but the cull of the 18 class size pledge has been on the cards for months.

“Again and again ministers have been asked to come clean on class sizes and again and again they refuse to answer. They simply can’t be trusted on education.”

City of Edinburgh Council education convener Marilyne MacLaren said urban authorities may have difficulty meeting the new demands.

She was "delighted" that legislation will be drawn up but added: "It has been something of a dog`s breakfast with the Scottish Government instructing us to decrease class sizes but not giving us the legal tools to do so."

Ms MacLaren, a Liberal Democrat councillor, said some schools will have to rely on adding teachers to large classes to keep the ratio down.

She continued: "We don`t have the money, we don`t have the physical capacity. In some schools we just could not cope with another classroom or two classrooms - there just isn`t the room.

"So we will do what we can with some of our very large primary schools which are pretty full and pretty tight on the sites."

Ms MacLaren added: "We will deliver in hopefully a majority of cases, or most cases, but we can`t deliver physically every single P1 consisting of 25 pupils, it`s just not possible.

"This is not just Edinburgh`s conundrum, it will be other large authorities too."

She said "team teaching" arrangements - where large classes are overseen by more than one teacher - were working well.