The Russian security services have a habit of filing drug charges against activists and journalists they find troublesome, sending them to jail for several years. Previous cases were in the provinces, however.

Moscow journalists pushed back immediately, pointing out that only one of the nine photographs of lab equipment and clear bags of white powder was actually taken in Mr. Golunov’s apartment. The police backed down, admitting that was true but contending that the pictures were related to a different case that might involve Mr. Golunov.

Next there was a tug-of-war over Mr. Golunov’s condition, with medics at the courthouse suggesting the reporter needed treatment for possible broken ribs and other injuries sustained during a police beating. After he was taken to a clinic and a Moscow doctor close to Mr. Putin pronounced him fit, the doctor was pilloried on social media.

On Saturday night, hundreds of supporters gathered outside the Moscow courthouse where Mr. Golunov was being arraigned, breaking out into periodic chants of “Freedom” or “Ivan.” When the judge ordered two months of house arrest, instead of being held in prison as the prosecutor requested, the crowd erupted in cheers.

It is extremely rare for any judge in a Russian court to contradict prosecutors, particularly in a case involving accusations over large quantities of drugs, so the house arrest was seen as an admission that the entire case was flawed. But Mr. Golunov could still be convicted and jailed.

Mr. Golunov and his employers said that they thought he was being punished for his work. In an aside to friends in court, Mr. Golunov said he thought his story about the funeral industry might have prompted his arrest, since he received threats afterward.

By Monday, the protests had moved well beyond the fraternity of journalists, and beyond Moscow as well. Demonstrations were held in numerous Russian cities and abroad.