The four men accused of carrying out Russia’s deadliest terror attack in decades appeared in a Moscow court on Sunday night bandaged and battered. One entered with his partially severed ear covered. Another was in an orange wheelchair, his left eye bulging, his hospital gown open and a catheter on his lap.

Many people around the world, including Russians, already knew what had happened to them. Since Saturday, videos of the men being tortured during interrogation circulated widely on social media, in what analysts called an apparent retaliation for the concert hall attack they are accused of committing last Friday, which killed at least 139 people and injured 180 more.

One of the most disturbing videos showed one defendant, identified as Saidakrami M. Rajabalizoda, having part of his ear sliced off and shoved in his mouth. A photograph circulating online showed a battery hooked up to the genitals of another, Shamsidin Fariduni, while he was being detained.

How the videos began circulating was not immediately clear, but they were spread by nationalistic, pro-war Telegram channels that are regarded as close to Russia’s security services.

Though the goriest clips were not shown on state television, the brutal treatment of the defendants was made clear. And the decision by the Russian authorities to showcase it so publicly in court, in a way they had almost never done before, was intended as a sign of revenge and a warning to potential terrorists, analysts said.

In Russia’s recent history, videos of torture were not shown on state television, said Olga Sadovskaya of the Committee Against Torture, a Russian human rights organization.