JOHANNESBURG, Feb 13 (Reuters) - South African police used stun grenades to quell anti-Somali rioting in a black township on Tuesday, the latest in a wave of violence that has killed over three dozen immigrants from the eastern African nation. Police arrested 27 people in the Motherwell township in Port Elizabeth in South Africa's Eastern Cape Province after dispersing an unruly crowd that was pelting Somali-owned shops with stones, according to SAPA news agency. The unrest followed the shooting of a 15-year-old boy, who was wounded when an armed gang attempted to rob a Somali shop. "The Somalis allegedly opened fire at the men and a 15-year-old boy, who was not involved in the robbery, was shot and wounded," Police Captain Ernest Sigobe told SAPA. More than 30 Somali shops were looted or vandalised after the shooting. Attacks against Somalis have become more frequent across South Africa in the past year, especially in the poor townships in the Western and Eastern Cape provinces, where many of the immigrants have settled and opened businesses. About 40 Somalis have been murdered in the Western Cape province alone in the past six months. The government and police in the province have been trying to determine whether the killings are part of a plan to drive out the immigrants. The Somalis' success with so-called "spaza" shops -- small stores that sell soft drinks, snacks and clothes -- has engendered resentment from some locals, who accuse them of undercutting local shopkeepers and stealing trade and jobs. Widespread poverty combined with the influx of large numbers of refugees and immigrants from other African nations also has led to rising tensions and xenophobia in many of South Africa's predominantly black townships. Zimbabweans, believed to be the largest African immigrant group in South Africa, frequently complain that they are targeted by criminals and harassed by police in Johannesburg and other major cities. (Reporting by Paul Simao, editing by Sophie Hares; via Johannesburg bureau +27 11 775 3165)