Flagship legislation requiring the Scottish Government and councils to tackle the attainment gap has been passed by Holyrood, despite concerns about the return of national testing for primary school pupils.

Education Secretary Angela Constance hailed the reforms as a "significant milestone for education in this country".

The Education (Scotland) Bill, which was unanimously agreed, places a duty on local authorities and ministers to prioritise measures to reduce the educational divide between youngsters from different backgrounds.

It also legislates for the introduction of a National Improvement Framework in Scotland's schools, which will bring in national assessments for youngsters in P1, P4, P7 and S3.

Campaigners at the charity Children in Scotland have insisted testing children in the first year of primary school is "simply not appropriate for their age'', while Liberal Democrat education spokesman Liam McArthur called on ministers to ditch the plans.

He raised fears that standardised testing would inevitably lead to school league tables, and said: "I would urge the Government to heed the calls of teaching unions, teachers and parents to drop plans for national standardised testing in primary schools."

The Liberal Democrat quoted Brian Boyd, emeritus professor of curriculum studies at Strathclyde University, who told him: "It is notable that the last time such an approach was introduced was by a Conservative government led by Margaret Thatcher, borne by a lack of trust in the teaching profession and narrow vision of what constituted progress."

Mr McArthur added: "Denials from the Education Secretary and First Minister that they are not ushering in a return to higher-stakes testing, teaching to the test and league tables is difficult to square with what is proposed.

"Information will be available on a school-by-school basis. Whether league tables are sanctioned by ministers or not, they seem inevitable."

Ms Constance argued that 30 out of Scotland's 32 councils already use a form of standardised assessment, adding that a national approach would improve the consistency of information.

She said: "This is a wide-ranging Bill covering measures important to key aspects of Scottish education. It forms part of the work this Government is undertaking to ensure excellence and equity are embedded throughout our education system."

She continued: "The common thread across this Bill's measures is a focus and concern to create an education system that is wholly centred and focused on children's interests and needs.

"The Bill places a strong duty on education authorities and ministers to address inequalities of outcome, it makes explicit the link between those inequalities and socio-economic disadvantage. That marks a significant milestone for education in this country in that we are now utterly focused on there being duties on national and local government to act to reduce the impact of poverty and inequality on children's learning."

Conservative Mary Scanlon welcomed the standardised assessment, but warned that councils must be supported in delivering the measures in the Bill.

Estimated costs have risen due to measures such as a guarantee of 25 hours of teaching time for every primary school pupil being added to the legislation.

She claimed the legislation is now up to 24 times the original cost with "very little indication of who is paying, where the money is coming from".

Labour's Mark Griffin said: "Any attempt to close the attainment gap is welcome, but we believe this piece of legislation could be so much more ambitious.

"And yet where the Government has shown some ambition, there are serious questions around the practicalities of delivery and the intent behind it, given the ever-reducing budgets of education departments in our local councils.

"We set out areas where we feel the Bill could have been improved -: a specific focus on looked-after children, reviewing resources available to support closing the attainment gap when new powers on taxation become available, international benchmarking and targets on reducing the attainment gap on literacy."

He also claimed questions remain over "how the Government will prevent testing data being used to compile crude national league tables".

Mr Griffin said: "We will support this Bill because anything that raises the issue of the attainment gap, and at least starts to describe the problem, is better than nothing at all, but we feel the Scottish Government could have been so much bolder."