The gap between pupils from the most and least deprived areas who go on to university, college or a job after school has closed by a fifth in one year, official figures show.

A record 92.9% of all school leavers in 2016-17 had gone onto "positive destinations" within nine months, according to Scottish Government statistic, up from 91.4% the previous year.

The proportion of pupils from the most deprived communities in Scotland who achieved this increased to 87.6% last year, narrowing the gap with their counterparts in the most affluent communities by 22%.

In the wealthier areas, 96.4% of all leavers were in a positive destination nine months after finishing classes.

The gap between the two has fallen to 8.7% - down from 12.9% in 2012-13.

Education secretary John Swinney hailed the "real improvement" in the figures, which also showed improved attainment by children in literacy and numeracy over the last four years.

But Scottish Labour warned ministers they shouldn't be "patting themselves on the back" at the improved statistics.

The party also said jobs on zero-hour contracts should not be counted among "positive destinations", which also include voluntary work.

The annual report into attainment revealed almost twice as many pupils from affluent areas left school with one good Higher pass or more compared to those from the worst-off communities.

More than 80% of school leavers in wealthier parts managed at least one Higher at grades A to C, compared to only 43% in the most deprived areas.

For children in care, only 16% of pupils left school with at least one good Higher pass.

Across Scotland, 38% of leavers went on to higher education, making it the most popular destination for pupils after school.

A total of 28% of pupils leaving school went into work, with 23% going on to further education.

Among children in care, the number in "positive destinations" after leaving school has risen from 40% in 2009-10 to 76% last year.

Swinney said: "These figures are indicative of a high-performing education system, which is testament to the efforts of our teachers, our school staff and our education leaders to give every child the opportunity to fulfil their full potential in life.

"Already the action of this government is delivering real improvement in our schools, and implementation of reforms to empower schools and school leaders will accelerate this.

"I'm particularly pleased to see an increasing proportion of looked after children leaving school with at least a Higher or equivalent, but clearly the gap is still too wide.

"The findings of the independent Care Review and this government's £750m investment through the Scottish Attainment Challenge will, I believe, see us make even more progress in closing the poverty-related attainment gap in years to come."

Labour education spokesman Iain Gray said: "Any progress in closing the gap between the richest and the rest is welcome but the SNP government should not be patting itself on the back too quickly, as there is still much more improvement is needed.

"These figures show that a young person from the richest background is almost three times more likely to go to university that a young person from the poorest, and that colleges, decimated by years of SNP cuts, remains a more likely route into education for working class young people.

"Figures of school leavers going onto employment - around one in four from the poorest backgrounds - also include young people on exploitative zero-hours contracts.

"The government should remove these jobs from positive destination figures.

"Labour does not believe insecure work is a positive destination for our young people."