Figures from the 2017 exam diet show pupils from the poorest backgrounds increased their attainment by two percentage points compared with those from the wealthiest areas, where average results stayed unchanged.
It means that those from the richest families still secured about twice as many qualifications as those from the most disadvantaged.
John Swinney, the education secretary, said: “Education is this government’s number one priority and we are investing heavily to ensure every child has an equal chance to succeed.”
He cited education reforms such as Pupil Equity Funding, which gives extra money to schools in deprived areas, as likely to narrow the gap further.
“While the figures are moving in the right direction, we recognise the scale of the challenge involved,” Mr Swinney said.
However, the data, published by Education Scotland, prompted widespread criticism of the SNP government, which has repeatedly stated that its main goal is to narrow the attainment gap and drive up standards in schools.
Liz Smith, education spokeswoman for the Scottish Conservatives, said the “marginal improvement” was welcome but added: “Several sets of recent statistics have laid bare the extent of the gap which remains between the most and least deprived pupils.
“None of this is helped by the on-going controversy over National 4 exams and whether too many pupils are being pushed into a qualification level that is not consistent with their abilities.”
Iain Gray, education spokesman for Scottish Labour, said: “After 10 years of SNP mismanagement of education, pupils from our richest communities continue to do far better than those from deprived neighbourhoods.”
Ross Greer, education spokesman for the Scottish Greens, said it would be “churlish” not to welcome any closing of the attainment gap, but that the narrowing had been very slight.
“Young people from the most deprived backgrounds are still being badly let down and we do not stand a chance of turning things around if we continue to see this as a problem which can be solved through education alone.
“While massive additional funding is needed in schools to reverse a decade of cuts, a direct attack on the causes of poverty itself is what’s needed.”
Liberal Democrat education spokesman Tavish Scott said: “Despite declaring it their main priority three years ago, the SNP government has moved sluggishly on closing the attainment gap.
“Class sizes are at their highest since the SNP took office a decade ago, there are hundreds of teaching vacancies, support staff have been lost, and ministers are behind in their childcare expansion.”
Stephen McCabe, education spokesman for council umbrella group Cosla, said progress was being made against a backdrop of real-terms cuts to budgets.