More than 2,000 people were arrested as masked riot police confronted tens of thousands of protesters.