Two Muslim worshippers stabbed to death in South Africa mosque attack
Several people were also wounded in the attack in the town of Malmesbury near the southwestern city of Cape Town, which took place around 3am.
"Malmesbury police were called out to a local mosque and found two people dead with stab wounds and several injured," Noliyoso Rwexana, Western Cape police spokesperson told AFP.
"The suspect believed to be in his thirties and armed with a knife charged at the police who tried to persuade him to hand himself over.
"He ignored the calls and tried to attack police. He was shot dead."
Police are now "combing the scene for clues", the spokesperson said.
The motive for the attack was not immediately clear.
It comes a month after a similar attack at a Shia mosque in the town of Verulam, on the outskirts of the eastern port city of Durban.
One man was killed when three men slit his throat and injured two others after midday prayers at the mosque.
Police are still searching for the attackers.
The motive was not clear, but police said it had "elements of extremism".
The Verulam attack appeared to be unprecedented in South Africa, where about 1.5 percent of the country's 55-million population is Muslim.
The country prides itself on religious tolerance and has little record of violence related to religion.