President Vladi­mir Putin’s foremost opponent defiantly challenged the Kremlin on Tuesday evening, hours after a court ruling that seemed cunningly designed to keep him in check.

A judge had sentenced the brother of Alexei Navalny, an anti-corruption activist and a scourge of Putin’s since 2011, to 3 1/2 years in prison while ordering Navalny himself to remain under house arrest.

Denouncing the move as a hostage-taking, Navalny defied the order and strode to the edges of a demonstration in central Moscow on Tuesday evening. Police quickly whisked him away, but he had shown that he would not buckle under an implied threat to his family.

He and his brother, Oleg, had been on trial on what they and their allies deemed trumped-up fraud charges. Supporters had expected that Alexei Navalny would be sentenced to the maximum of 10 years, but authorities appeared reluctant to make a martyr out of him, and he got off easily. His less political brother was not as fortunate.

Navalny’s supporters decried the legal system for incarcerating the relative of a political foe.

A small but angry crowd that gathered in Manezh Square called for Oleg Navalny’s release, and chanted, “I am Navalny’s brother.”

Timeline: Alexei Navalny, a life in opposition

Alexei Navalny made no secret of his presence at the demonstration, tweeting selfies from the subway train he took to get there. His intention in showing up was to reinvigorate the opposition movement at a time when Putin’s image has suffered over international crises and a slumping economy.

But if Navalny was trying to seize a political moment by daring authorities to accommodate or arrest him, the state wasn’t willing to take that bait.

Police detained Navalny as he approached the square outside the Kremlin where his supporters had gathered in frigid temperatures, but instead of throwing him in jail for breaking his house arrest, they simply returned him home.

It was not the first time Navalny had been detained at a protest. But given the terms of his house arrest, authorities could have taken a harder line — and they still might.

For now, authorities are keeping to a strategy of tying Navalny up with legal proceedings without cracking down so hard as to provoke street protests of the size he led in 2011 and 2012.

Tuesday began with a jarring surprise when Navalny was given a 3 1/2- year suspended sentence with no jail time, while his brother was imprisoned immediately following the verdict.

“Shame on you!” Navalny cried to the judge. “Why are you putting him in jail, just to punish me even more?”

In Washington, State Department spokesman Jeff Rathke called the Moscow court decisions a “disturbing development designed to punish and deter political activism.”

At the nighttime rally, Maria Krasovskaya, 24, said, “Putin is pure evil — he can choose very evil ways of treating people, and he created this hostage situation.”

She complained that Russian authorities have no respect for the rule of law. “Of course he was hoping that people wouldn’t care about some Oleg Navalny that they’ve never known, but I’m glad some people do.”

Krasovskaya was one of about 2,000 people who showed up on the coldest night yet of Moscow’s winter.

According to one watchdog group, OVD-Info, more than 250 people were detained for participating in the unsanctioned demonstration.

Turnout fell far short of what demonstration organizers initially expected, before the court pulled a last-minute scheduling switch, changing the date of the verdict from Jan. 15 to Tuesday with less than 24 hours’ notice.

Tens of thousands had pledged to come to the Jan. 15 rally, despite the Russian government’s efforts to remove Facebook event pages advertising the unsanctioned demonstration.

The Tuesday verdict came just before the new year, a holiday in Russia and the start of an extended national vacation period during which many people leave Moscow. That timing — and the weather — kept some supporters at home.

It is not the first time the government has taken note of Navalny’s ability to draw a crowd and reacted accordingly.

In 2013, when a court found Navalny guilty of embezzlement in a different case involving a timber company, authorities released him from prison after just one day following large protests in Moscow. He placed second in the Moscow mayor’s race, drawing a larger-than-expected 27 percent of the vote, a few months later.

In the current case, Navalny and his brother were accused of defrauding a local affiliate of the Yves Rocher cosmetics company out of $800,000 through inflated shipping bills. Navalny has been under house arrest since February.

Many of Navalny’s supporters said they had been deeply disturbed by the decision to punish Navalny’s brother and the precedent it might set for others to be found guilty by association in the future.

“We didn’t just come for him, we came for ourselves,” said Kasim Alpaev, 59. “To come for yourself or not, that’s an important question. Are you going to just sit in your house and dream? I can’t.”

Carol Morello in Washington contributed to this report.