More than a quarter of children are not achieving the expected levels of literacy and numeracy as they finish primary school, according to new figures.

Statistics looking at the number of children considered by teachers to be performing at the required level for their age in Curriculum for Excellence (CfE) have been published by the Scottish Government for the first time.

They show the proportion of pupils achieving the relevant level for their school year decreased throughout the primary stages.

The figures revealed that 72% of P7 pupils achieved the required level, down from 75% in P4 and 81% in P1.

Curriculum areas measured include reading, writing, listening and talking and numeracy.

For P7, attainment levels as measured by teachers were 72% for reading, 65% for writing, 77% for listening and talking and 68% for numeracy.

The statistics showed an improvement in secondary school, with the proportion of S3 pupils achieving CfE third level or better between 84% and 87% for each curriculum area.

For each area, a higher proportion of pupils living in the least-deprived areas achieve the CfE level relevant to their stage compared to pupils living in the most-deprived areas.

The gap between pupils from the 20% most-deprived areas and those from the least-deprived areas for writing at P7 is 23%, for example.

The publication comes a week after it emerged Scotland's schools had recorded their worst-ever performance in the latest set of Programme for International Student Assessment (Pisa) figures.

Separate data showed there were 50,970 teachers in 2016, up by 253 full-time equivalent on last year.

Class sizes in P1 to P3 are the same as last year and broadly the same across primary school.

The pupil-teacher ratio remains unchanged for the third successive year at 13.7.

Deputy First Minister John Swinney said: "I very much welcome the rise in teacher numbers compared to last year.

"We can also see that class sizes are broadly stable and the pupil-teacher ratio has been maintained. This is all good news, particularly when you consider the teacher recruitment challenges being faced in some areas.

"The initial teacher judgement data, published today for the very first time, illuminates progress being made in different parts of the country and by children in our least and most deprived areas.

"These figures shine a light on where excellence already exists and where there is more to do, both to target resources and to ensure that children are getting the right support at the right time.

"They come ahead of the introduction of standardised assessments next year and provide a basis upon which to build our knowledge about how children are progressing at school.

"The wide variation in some of the data does, however, highlight the value that standardised assessment will bring.

"Currently there are inconsistencies in the way young people's progress is being assessed and reported in schools across the country.

"The standardised assessments will provide teachers with nationally consistent data to help inform their professional judgement."

Teaching union EIS welcomed the figures on teacher numbers.

General secretary Larry Flanagan said: "The EIS would certainly expect the Scottish Government to continue its commitment to maintaining teacher numbers and we hope to hear confirmation soon from the finance minister in his forthcoming financial statement."

On CfE attainment, he added: "The publication of CfE level data today indicates that pupils in our schools are performing well overall and that most are at or ahead of the expected level for their stage.

"The data also confirms some challenges that we know exist, such as the link between deprivation and poorer attainment and the challenge of maintaining momentum during the transition phase between upper primary level and early secondary level.

"These are issues that teachers are working hard to address and the continuing investment by the Scottish Government is important in tackling these major societal issues that continue to impact on pupils in our schools."

Scottish Greens education spokesman Ross Greer said the CfE figures amounted to league tables.

He added: "While other parties have pushed the Scottish Government down the road of standardised assessments, Greens have been clear in calling for teachers to be given time to teach.

"Instead we see deeply-flawed league tables being published that can only increase stress for parents, pupils and teachers.

"The Education Secretary will doubtless point toward his proposed reforms but talk of governance changes is a complete distraction and, in any case, it's the wrong kind of change being proposed.

"The real priority should be raising the money needed to fully fund our local councils so they can get on and deliver what our schools really need."

The Conservatives highlighted the wide variation between local authorities in the CfE data.

"It's clear from these figures that there are massive issues in delivering CfE in some areas of the country and that the confusion surrounding its implementation is starting to have a hugely negative effect," education spokeswoman Liz Smith said.

Labour's Iain Gray added: "Pupils not reaching expected standards in reading, writing and numeracy is a failure in social and economic policy by the SNP government.

"It would be shameful if the SNP government, having seen these figures, elected to cut local education budgets again on Thursday."