Even before the rally got underway, police officers in camouflage and black helmets started detaining some protesters, although it was hard to discern any pattern to who was snatched off the street.

As the crowd swelled in size in the afternoon, the situation grew increasingly tense.

Yulia Navalnaya, Mr. Navalny’s wife, was taken into custody at a rally in Moscow and posted a photo of herself in a police wagon on Instagram.

At one point police officers rushed into a group of protesters, swinging batons. Some in the crowd responded by throwing objects, including what appeared to be plastic bottles, at the police.

Hundreds of people packed the sidewalks of one of Moscow’s main thoroughfares leading to the square, for at least half a mile. There were repeated tussles between protesters and the police.