MOSCOW -- Russian opposition leader Aleksei Navalny says he has been released from custody after he and thousands of other protesters were detained as part of nationwide protests ahead of President Vladimir Putin's inauguration for a fourth presidential term.

‘‘They wrote up two protocols on me: organizing a rally and disobeying police, but at half past midnight they chose to release me pending trial,” he wrote on Twitter early on May 6.

Veronika Polyakova, a lawyer for Navalny's Anticorruption Foundation, told Interfax that the case will be heard at Moscow's Tverskoi District Court on May 11.

Navalny and hundreds of other protesters were detained by police at an unsanctioned demonstration on May 5 in Moscow.

Navalny was taken into custody shortly after arriving at the rally on Pushkin Square in the center of the Russian capital, where riot police carted away other protesters and some were beaten by pro-Putin vigilantes.

Video showed police carrying a struggling Navalny out of the square, holding him by the legs and arms.

Navalny has already served several jail terms on charges related to organizing antigovernment protests.

Media reports said the number of protesters in Moscow was in the thousands. Police said the crowd numbered some 1,500 people, but officials routinely downplay the size of opposition protests in Russia. About 1,000 people participated in the rally in St. Petersburg.

"I think that Putin isn't worthy of leading this country. He has been doing it for 18 years and has done nothing good for it," Moscow demonstrator Dmitry Nikitenko told the Associated Press. "He should leave for good."

According to the independent police-monitoring group OVD-Info, some 1,612 people have been detained in 26 cities nationwide in connection with the rally. Some of those detained were reportedly minors.

Russian opposition leader Alexei Navalny in Pushkin Square in Moscow on May 5, before his detention

In Moscow alone, the number of detainees was 703, while 233 protesters were detained in St. Petersburg.

Moscow police issued a statement saying that "about 300" people had been detained in the capital. No official figures were given for the country as a whole.

Under the slogan "He's Not Our Tsar," Navalny, 41, had called on supporters to take to the streets ahead of Putin's May 7 inauguration to protest what Navalny says is Putin's autocratic rule. In a post on Twitter on May 4, Navalny called Putin "a craven old man."

"We will force the authorities, comprised of swindlers and thieves, to take into account the millions of citizens who did not vote for Putin," Navalny said on May 4.

Putin is due to be sworn in for his fourth term on May 7, extending an 18-year reign that his supporters say has lifted the country "from its knees" and is denounced by his opponents as a corrupt, calcifying authoritarian kleptocracy.

Navalny, who has organized large street protests and published numerous reports documenting alleged corruption by Russia's ruling elite, was barred from running in the March presidential election due to a conviction on financial-crimes charges he contends were fabricated.

Authorities in Moscow warned Navalny supporters in advance against taking part in the protest, calling it "absolutely unlawful."

Riot police in the capital detained protesters, while men in traditional Cossack dress were seen beating some of the demonstrators as a police helicopter flew above the crowd.

Among the crowd on Pushkin Square were pockets of pro-Putin supporters, many of them young men, who shouted "Our country, our rules" and "We are for Putin."

As videos and photos of police roughly manhandling unresisting protesters flooded social media, Moscow police spokesman Vladimir Chernikov was quoted as saying "the police and National Guard today acted strictly in accordance with the law, competently and calmly."

"Unfortunately, as we expected, there were provocations on the part of the organizers of the unauthorized rally," he continued, according to Interfax.

Many of the protesters were charged with the administrative violation of disobeying police and are being released pending hearings.

U.S. State Department spokeswoman Heather Nauert posted on Twitter that the United States "condemns Russia's detention of hundreds of peaceful protesters and calls for their immediate release."

"Leaders who are secure in their own legitimacy don't arrest their peaceful opponents for protesting," she wrote.

A spokeswoman for European Union foreign policy chief Federica Mogherini issued a statement saying the police reaction in Russia threatened "the fundamental freedoms of expression, association, and assembly in the Russian Federation."

"Even if some of the demonstrations were not authorized in the location where they took place, this cannot justify police brutality and mass arrests," the statement said, adding that the EU expected Russia to "release without delay peaceful demonstrators and journalists."

With material from Current Time TV, AFP, Interfax, and Reuters

RFE/RL's Radio Svoboda is the leading international broadcaster in Russia. As Russia witnesses increasing control of the media by state authorities, Radio Svoboda has become a key forum for those who lack access to other means of free expression.