CAPE TOWN — Under pressure from education activists and the courts, South Africa’s government announced on Tuesday that it would tackle a crippling sanitation backlog in schools, where two children recently drowned in pit toilets, the only facilities available for hundreds of thousands of children across the country.

The initiative, known as Sanitation Appropriate for Education, would “spare generations of young South Africans the indignity, discomfort and danger of using pit latrines and other unsafe facilities in our schools,” said President Cyril Ramaphosa at a kickoff in Pretoria, calling the lack of school sanitation facilities an “emergency.”

But education activists said the announcement was long overdue and not nearly enough to solve a crisis that has been brewing for years.

Nearly 4,000 schools nationally are equipped only with pit toilets, according to government figures. In the Eastern Cape, South Africa’s poorest province, one in four public schools have no other options for students to relieve themselves.