People carried Brazilian flags and signs with the popular slogan 'Bolsonaro out!'.
The demonstrations took place days after Bolsonaro urged his sympathizers to mobilise against his perceived enemies in Congress and the courts on Independence Day.
Former Health Minister Luiz Henrique Mandetta, who was fired by Bolsonaro in April 2020 after clashing with him over how to fight the new coronavirus, attended the event.
"Today democracy itself is at risk," he said. "This is not just the younger generation's fight, it's everyone's."