MOSCOW — Russian authorities sentenced three feminist punk rockers to two years in prison Friday, showing that protest will be punished even as they avoided the harshest penalty possible. The case against the women — who dashed into Moscow’s main cathedral to sing a song directed against Vladimir Putin — has inflamed the pro-democracy movement here and around the world and put the Kremlin in a dangerous position.

Putin, prime minister when the song was sung in February and now president, has made it clear that dissent here will have its limits. The two-year sentence appeared to be an attempt to reinforce that message without fueling more widespread protest.

Prosecutors had asked for three years — the charge of hooliganism motivated by religious hatred carries a maximum of seven years — but after nearly three hours spent reading a summary of the trial from a red, leather-bound book, the judge said each woman would get two years. The case was so controversial that the judge’s face was not shown on the video feed for those who could not pack into the crowded courtroom. The defense said it would appeal the sentence.

The women, Nadezhda Tolokonnikova, 22, Maria Alekhina, 24, and Yekaterina Samutsevich, 30, have been in jail since March. They are members of a feminist collective called Pussy Riot and were relatively unknown singers and activists until their protests coincided with a rise in anti-government sentiment over the winter.

Now they have become an international cause, described as prisoners of conscience and caught up in a show trial reminiscent of the days of Stalinist repression. A sentence of time already served would have been seen as a sign of Kremlin tolerance for dissent; a sentence of three years or more would have been interpreted as an indication that Putin wants to put down all challenges to his presidency, no matter the cost.

But on Friday, the shorter sentence was slammed by rights groups as evidence that Russia was repressing dissent. And the United States expressed disappointment over the decision.

During his daily briefing, White House deputy press secretary Josh Earnest said, “While we understand the group’s behavior was offensive for some, we have concerns about the way these young women were treated by the Russian judicial system.”

Alexei Navalny, the crusading anti-corruption activist, wrote on his blog that though he believed the band’s stunt was foolish, “obviously, this unjust and cruel decision will increase anticlerical sentiment and aggressive criticism of the Russian Orthodox Church.”

Human Rights Watch released a statement from Hugh Williamson, the group’s Europe and Central Asia director. “It’s clear in this case that the women’s aim was to make a political statement, and it’s also clear that some found their actions offensive. But there is still a long way to go between an offensive political statement and a hate crime,” Williamson said. “The case against the Pussy Riot band members seems aimed not at protecting public order and security but at setting boundaries for political criticism.”

Amnesty International called the ruling a “bitter blow” for freedom of expression.

“Today’s verdict is a travesty,” said Michelle Ringuette, chief of campaigns and programs for Amnesty International USA. “The decision to find guilty Maria, Ekaterina and Nadezhda amid global outrage shows that the Russian authorities will stop at no end to suppress dissent and stifle civil society.”

In a statement, Innokenty Grekov of Human Rights First called on the U.S. government to “send a firm signal that a country that persecutes dissent and violates basic rule of law principles cannot be a trusted partner in the international community.”

The judge’s recitation Friday dwelled on what sounded like an offense to the church rather than the state. She quoted at length witnesses who said they were believers deeply offended by the one-minute performance.

One witness said that the young women violated the Cathedral of Christ the Savior dress code with their short dresses and that women were expected to behave modestly in church. Another said public prayers were not permitted in the cathedral without the presence of a priest. If that wasn’t bad enough, one witness said, the performance occurred just before Lent.

While the judge plowed through her 80 pages of text, a crowd of about 1,000 had gathered outside, mostly supporters of the young women who shouted anti-Putin slogans and chants of “Down with a police state.” A string quartet played on the sidewalk.

Many in the crowd shouted “Russia without Putin,” and others called out “Christ is risen.” A few Orthodox believers waved icons. One carried a sign saying, “It’s porno, not art.”

As the court convened, police wearing black berets waded into the crowd, plucking out demonstrators here and there and hauling them off to police vans. Among those arrested was Garry Kasparov, the chess champion and anti-Putin activist.

The trial came as the Russian parliament passed a series of laws in July meant to contain protest by requiring human rights and election-monitoring organizations, among other groups that receive foreign funds, to register as foreign agents. Another law imposes huge fines for slander. Violations of rules governing public gatherings also carry the threat of substantial fines, as well as prohibition from organizing protests.