The South African government's failure to provide textbooks to all state school pupils violates their constitutional right to an education, the high court has ruled.
The case was brought by human rights activists on behalf of several schools in the Limpopo province.
The court in Pretoria gave the government until 15 June to supply the schools with the textbooks.
The government has admitted that 80% of state schools are failing.
In a recent report, it said 1,700 schools were without water and another 15,000 had no library.
The country's education system is also struggling to overcome corruption and maladministration and low morale among teachers, correspondents say.
On Thursday, Judge Jody Kollapen ruled that the matter of supplying textbooks to the affected Limpopo schools was urgent.
He ordered the department of basic education to come up with a "catch-up" plan to resolve the issue by 15 June.
Members of Section27, the rights group which brought the case, hailed the verdict.
It said that some 1.7m learners at more than 5,000 schools in Limpopo "will benefit" from the ruling.
But it blamed the country's education department for "not doing its core business".
"We want to work with them, but we also want them to stop their arrogance," Section27 director Mark Heywood was quoted as saying.
"They should not have arrogantly told this court that the catch-up plan was a monumental waste of time."
South African Education Minister Angie Motshekga has recently pledged that 85% of all pupils in the country's state schools will have all the necessary textbooks by 2014.