A 30-year-old man was shot and killed, and an imam was injured in an attack on a Cape Town mosque, police said on Friday.

"According to reports the incident occurred on Tuesday at 19:00 at a mosque at Ntlazane Road, Khayelitsha," police spokesperson Sergeant Noloyiso Rwexana said.

"Police arrived at the scene and found the victims with gunshot wounds to their bodies."

The four men had reportedly opened fire while worshippers were praying, IOL reported on Friday.

The 30-year-old man died on the scene due to his injuries, while the imam was transported to hospital for further treatment.

The funeral of the man was held on Wednesday. No arrests have been made yet.

Earlier this year, two worshippers were killed and several wounded in a stabbing attack at a Malmesbury mosque in June, News24 reported.

READ: 2 killed, attacker shot dead in stabbing attack at Malmesbury mosque

The Hawks said in a statement that the attacker had been identified as 23-year-old Nur Arawal from Somalia.

Arawal was an outpatient at Bellville's Karl Bremer psychiatric hospital from 2013 until recently, Hawks spokesperson Hangwani Mulaudzi said.

Arawal was shot dead by police officers following the attack.

READ MORE: Verulam mosque attack - 'They have committed heinous crimes'

KEEP UPDATED on the latest news by subscribing to our FREE newsletter.

- FOLLOW News24 on Twitter