Two teenaged boys were hurt by the rubber bullets, a spokesman for families fighting eviction said.
Police Captain Andre Traut said stun grenades were also used to "prevent any form of violence" in Delft, near Cape Town.
"The crowd became violent and started throwing stones at (police) members," said Traut.
The South African government has promised to improve housing. The problem is a legacy of apartheid rule and becoming increasingly difficult to manage because of a steady flow of people moving to already congested areas.
Officials say the country has made progress in easing a huge backlog in requests for housing but still needs to spend billions of dollars to ease a nationwide crunch.
Critics say President Thabo Mbeki's government has favoured big business over the poor, many of whom still live in grim townships 14 years after the end of white minority rule.
"The ANC-led government remains committed to the objective of providing decent housing to all South Africans," the ruling African National Congress (ANC) said in a statement on Tuesday.
Some 1,600 families are fighting eviction from the housing project, said Ashraf Cassiem, chairman of the Western Cape Anti-Eviction Campaign, which represents the families.
"Police opened fire with rubber bullets, injuring two teenage boys in school uniform... The situation is extremely volatile," he said.