Morning prayers were disrupted by gunfire at Isidingo Primary School when a woman teacher was shot and killed at close range by four armed men.
The incident happened at the start of the school day in Umlazi near Durban yesterday.
The shooting has left pupils, teachers and the community of Umlazi's G section shocked.
Mpho Shibe, 42, a contract staff member, was walking up to join morning assembly when she was killed.
Morning assembly was under way, with pupils singing hymns to piano accompaniment when the shots rang out.
A security guard at the school said Shibe was shot after entering the first gate, which leads to the main entrance where he was on duty.
"I heard gunshots and went to investigate,"the guard said. "I saw the teacher who had been walking with Shibe run towards the second gate. Shibe was lying in a pool of blood.
"She died on the scene."
Learning at the school was suspended for the day.
Teacher unions have criticised the education department for failing to provide security at schools.
The police said the motive for the shooting was not robbery.
"Nothing was taken from the victim or the colleague she was walking with," said police spokesman Daniela Veldhuizen.
The chairman of the South African Democratic Teachers' Union in Umlazi, Bheki Fakazi, said: "Schools are the only workplace where criminals walk in and out as they please."
National Teachers Union spokesman Allen Thompson said it was time the department took the issue of safety seriously.