A prominent South African MP fired shots to fend off a violent attack by a gang on him and two of his colleagues in Cape Town.

Ian Cameron - along with two other members of parliament's police committee, Lisa Schickerling and Nicholas Gotsell - were returning from a work trip when their vehicle was ambushed in the township of Philippi on Tuesday.

The assailants smashed the car's windows with bricks, injuring Cameron and Gotsell.

Cameron, whose teeth were broken, retaliated by opening fire, injuring one of the attackers.

Police said two teenagers, aged 16 and 18, have been arrested as they investigate a case of attempted murder and attempted hijacking.