At least 27 people have been killed in two separate mass shootings in South Africa's Johannesburg and Cape Town, according to police.

In the first incident, gunmen attacked a bar in Wedela, southwest of Johannesburg, on Saturday night. Police said 17 people, including 13 men and four women, were killed, while 15 others sustained injuries.

The attackers reportedly opened fire on customers outside the bar before moving inside. They also set two vehicles ablaze before fleeing the scene.

Police said the motive for the attack remains unclear, although preliminary investigations suggest it may have been linked to a previous incident at the same tavern.

In a separate attack early on Sunday, gunmen opened fire at a barbecue venue in a township outside Cape Town, killing 10 people and injuring 11 others. Police said five victims died at the scene, while the others died while being taken to hospital. Two of those killed were women.

No arrests have been made in connection with either shooting. The attacks come amid persistent gun violence in South Africa, which authorities say is often linked to gangs, organised crime and local business disputes. President Cyril Ramaphosa said security forces would intensify efforts to reduce criminality and violence in the country.