The 1976 protests, and the apartheid regime's violent response, fuelled a struggle that eventually led to the fall of white-minority rule with Nelson Mandela's election as president in 1994.
The anniversary has been commemorated by a series of events to honour those who took part in the uprising, which began as a protest against a government order that schools could only teach in the Afrikaans language used by whites.
"(The students) were dreaming about good quality education, they were dreaming about a new democracy," Jeff Radebe, a senior government minister, said at the start of the official ceremony at a stadium in Soweto.
At the time at least 170 people were killed, with some estimates putting the death toll at several hundred over the following months as the uprising spread from the township of Soweto, south of Johannesburg.
Also Read
Images of poor, young black students gunned down by white police brought the injustices of apartheid to the world's attention and spurred the global anti-apartheid movement.
President Jacob Zuma was due to make a national address at the stadium, after Deputy President Cyril Ramaphosa placed a wreath at the memorial to Hector Pieterson, who was killed aged 13.
Divisions along racial lines remain strong in South Africa, with most black people enduring worse education, housing and unemployment than white people.
Students have again been protesting in recent months over tuition fees that force some poor black youths out of education.
Racist Internet postings have underlined long-standing frictions worsened by the country's dire economic performance and anger at politicians' failure to meet post-apartheid expectations.
Highlighting the country's unhealed wounds, a reconciliation event in Soweto last Saturday was sparsely attended.
Dan Montsitsi, a student leader of the uprising, said the 1976 march in Soweto had been planned for months.
The students, most of whom were in their school uniforms, carried placards reading: "Afrikaans stinks", "To hell with Afrikaans" and "Afrikaans needs to be abolished".
"We were amazed with the number of students that we had been able to put in the streets," he told AFP ahead of the 40th anniversary.
He said the police released a dog into the crowd, which was killed.
"(Soon after) they started to shoot."
June 16 is a national holiday in South Africa marking Youth Day.