CAPE TOWN (Reuters) - Two worshippers were stabbed to death and another two injured early on Thursday at a mosque near South Africa’s tourist city of Cape Town by an attacker who was shot dead by police.

Police tape cordons off a mosque after a knife attack in Malmesbury near Cape Town, South Africa, June 14, 2018. REUTERS/Mike Hutchings

The attack comes a month after three men armed with guns and knives slit the throats of three worshippers at a mosque north of the port city of Durban, killing one person and seriously injuring two others.

The Muslim Judicial Council (MJC) said worshippers, one of them in his 70s, were performing “l’tikaf” or seclusion in the mosque when the knifeman entered and joined congregants in morning prayers.

“Just after 3 a.m., when the worshippers retreated to rest, the assailant attacked the imam first and then murdered the members who came to the imam’s defence,” it said in a statement.

It named the deceased as Ismail Bassa, 74, and Somali national, Ziyaad Haseen Hedick, age unknown.

Police said the attack near Durban showed “elements of extremism”. They did not comment further on the motive behind the killings in Malmesbury, a small farming town 40 miles (65 km) north of Cape Town.

The city and the Western Cape province in which it is located is home to the largest community of Muslims in South Africa.

“The suspect, believed to be in his thirties and armed with a knife, was still on the scene and charged at the police who tried to persuade him to hand himself over,” police said in a statement. The suspect was shot as he attacked officers, police said.

The matter is being handled by the police’s elite Directorate for Priority Crime Investigation unit.

Africa’s most industrialized country has a large expatriate community and attracts many tourists but has seldom been associated with Islamist militancy.