Police quickly surrounded the building in Malmesbury near Cape Town outside which a body lay under a tree and a penknife was discarded nearby, according to an AFP correspondent at the scene.
"Provincial detectives are now combing for clues following the stabbing to death of two people at a mosque in Malmesbury in the early hours of this morning".
The country's Muslim Judicial Council said it was "shocked to its core to learn of a brutal attack on the Malmesbury Masjied [near] Cape Town in the early hours of this morning".
Officers said in a statement: "Police were called out to a local mosque and found two people stabbed to death and several injured". But when he ignored their calls, police opened fire - killing him at the scene.
Three people including a police officer were injured.
The suspected attacker lies dead in a field outside the mosque in Malmesbury, near Cape Town after he was shot by police.
Shujaat Bukhari- Know something about his career
The condition of the two injured in the shooting, which comes two days before Eid , is critical, they said. Frontline Editor R Vijaysankar said Bukhari's shocking demise was a great loss to the world of journalism.
The MJC appealed to the community to not jump to conclusions about the attacker's motives and said its top leadership would travel to the area to assist the community.
"Provincial detectives are combing a crime scene for clues following the death of two people at a mosque in Malmesbury during the early hours of this morning‚" said police spokesman Lt-Col André Traut. He was shot and killed in the process.
An investigator attends to the gates of the mosque after a knife-wielding assailant fatally stabbed two people. "It was an unknown guy; the guy asked for shelter for the night", he said.
It comes just a month after a deadly stabbing at another South African mosque which police said had "elements of extremism" and left an Islamic leader dead.
Mukaddam said it was tragic that "we started Ramadan with the atrocity in Durban and we're ending it with a tragedy in the same note".
Mumin Taaq said: "Enemies of Islam can only benefit from this".