The West Africans are accused by Rustenburg residents of drug-dealing and promoting prostitution.
The police used rubber bullets and smoke grenades to disperse a crowd chanting outside the magistrate's court, after they threatened to burn down the building which was in session.
The session concerned the hearing of a bail application of 14 Nigerian men accused of public violence recently.
The protesters threatened to torch the court, demanding that the sitting judge should not grant the men bail but to deport them to Nigeria.
The Nigerians were arrested on 21 January after they allegedly blocked the Rustenburg police station.
They had gone to the station to complain that they were being attacked by the locals and that the police were not helping them in stopping the violence.
Earlier on 10 January local taxi drivers had spearheaded a "raid" on alleged Nigerian-run brothels and drug dens after a local taxi driver Lebogang Motlhabane was allegedly kidnapped by local drug addicts and stabbed in December.
He went missing on 15 December and was found stabbed and tied up in the bush on 27 December.
He was taken to hospital where he died on 3 January.
Following Motlhabane’s death, taxi operators accused the Nigerians of selling drugs that led to South African addicts robbing people and killing the local residents for their money.
These accusations led to a rampage targeting West Africans, in efforts to clean up Rustenburg of drugs and prostitution, the residents claimed.
Eight guest houses suspected of operating as brothels and drug houses were torched in the violence, according to the police.
During the Friday hearing, Chief Magistrate Ronnie Rampe walked into the courtroom, scribbled a message on a piece of paper and handed it over to Magistrate Ziphora Phage, who is presiding over the matter.
Phage briefly adjourned the proceedings, and when she returned, announced that the hearing would be adjourned as there was a threat to burn down the building.
The case has been postponed to 13 February, with the Nigerians remaining in custody until next week.