Protest organisers had called for a million-strong demonstration at Taksim Square, but the entire area was cordoned off, making access impossible. Stretches of the motorways encircling Istanbul were also closed by police to try to prevent protesters getting to the city centre.
The opposite conditions applied to government supporters making their way en masse to hear the prime minister. The Istanbul municipality and the AKP laid on buses and other transport to help boost the numbers attending.
Erdogan inveighed against the international media, blaming the BBC and CNN for distorting the drama of the past three weeks in what he repeatedly alleged was an international plot to divide and diminish Turkey.
"You will make your voice heard so anyone conspiring against Turkey will shiver," he told the crowd. "Turkey is not a country that international media can play games on."
He added that the Turkish nation "is not the one banging pots at nights", in reference to what has become a soundtrack to the protests: middle-aged people coming on to their apartment balconies nightly to hammer on kitchen utensils.
The same din was heard across several central Istanbul neighbourhoods on Sunday evening.
While Erdogan addressed the massive crowds in bright sunshine, much of the city was sullen and tense. In several districts middle-aged women kept up a steady racket by beating pots and pans from their balconies as riot police lounged around, sitting on pavement verges.
The police raids, which started on Saturday afternoon and quickly cleared and occupied Gezi Park, included acts of startling brutality that outraged normally apolitical Istanbul citizens, as well as human rights monitors.
Teargas was fired into impromptu medical clinics housed in tents. A luxury hotel on Taksim Square being used as an emergency refuge for victims and for the wounded was repeatedly invaded by the police and teargas fired into the enclosed spaces.
"It was horrible in there," said Mehmet Polat, 32. "They shot teargas inside the hotel several times, the gas rose up to the sixth floor of the hotel, everything was filled with white smoke."
Another young man next to him nodded. "People were shoving each other, panicking, but the police kept attacking us." Both were not giving up. "Our demands are very clear," Polat said. "And until they are met, we are not going anywhere."