She was arrested after posting pro-Ukrainian views on social networking sites and giving food and clean clothes to Ukrainian soldiers when they approached the outskirts of her town. Rebels who searched her house found binoculars, she said.

Ms. Dovgan denied that she was a spotter aiding Ukrainian artillery units, and said the separatists never had any evidence that she was. She said she had been forced to stand on the sidewalk while passers-by beat her and spit on her because she refused to incriminate herself after a nightlong beating.

“I just wanted to die,” she said of the ordeal. “I lost myself. I thought: ‘This is my fate. God wants this for me. This is how it should be. Somebody should endure this.’ ” Rebel soldiers fired pistols beside her head in mock executions and beat her severely, leaving bruises on her arms and legs.

A report by the United Nations released last week that documents the conflict’s toll on civilians drew attention to indiscriminate shelling of residential areas by the Ukrainian Army and a wide range of abuses by pro-Russian separatists, including “killings, abductions, physical and psychological torture.” The report did not provide a definitive figure for the number of people held prisoner by separatists, but as of mid-August at least 498 people were believed to have been detained, often under harrowing conditions.

Separatists, who have introduced the death penalty for some offenses, have paraded prisoners of war in Donetsk and in Luhansk and compelled detainees to stand in public wearing signs hanging from string around their necks that listed their supposed crimes, much as Ms. Dovgan was forced to do.

Artillery barrages by unseen Ukrainian gunners that kill and wound dozens of residents of eastern Ukrainian towns daily have stirred rage. In Donetsk, as in other towns shelled in the conflict, that rage has been channeled into a hunt for artillery spotters.

After her release, Ms. Dovgan met Mauricio Lima, whose photograph drew wide attention to her plight after its publication in The New York Times last Tuesday.

“Thank you,” she said, and then she hugged him.