MOSCOW (Reuters) - A Russian historian whose exposure of Soviet leader Josef Stalin’s crimes angered state officials was cleared of child pornography charges on Thursday after a long campaign by human rights activists to free him.

FILE PHOTO: Historian Yuri Dmitriev accused of using his adopted daughter to produce child pornography, of illegally possessing a firearm, and of depravity, is escorted by a police officer upon his arrival for a court hearing in Petrozavodsk, Russia June 5, 2017. REUTERS/Igor Podgorny

State prosecutors had accused Yuri Dmitriev of involving his adopted daughter, then 11, in child pornography, of illegally possessing components of a firearm, and of depravity involving a minor.

But some of Russia’s leading cultural figures had said Dmitriev was framed because his focus on Stalin’s crimes jarred with the Kremlin narrative that Russia must not be ashamed of its past.

His real crime, they said, was dedicating himself to documenting Stalin’s 1937-38 Great Terror, in which nearly 700,000 people were executed, according to conservative official estimates. Dmitriev found a mass grave with up to 9,000 bodies dating from the period.

Dmitriev’s lawyer, Viktor Anufriev, told Reuters on Thursday that a court in Petrozavodsk in northwest Russia had cleared Dmitriev of the child pornography and depravity charges.

“We got 90 percent of what we wanted,” said Anufriev. “He was cleared of all the dirty charges.”

However, he said the same court had found his client guilty of illegally possessing “the main elements of” a firearm, something Dmitriev denied.

Anufriev had previously said that Dmitriev owned parts of a sawn-off shotgun, but that it was an old hunting rifle that did not fire, and that no bullets had been found.

State prosecutors had demanded Dmitriev be jailed for nine years. Anufriev said that his client would now face certain restrictions on his freedom of movement for the next three months as a result of the fire arms conviction.

Dmitriev, head of the local branch of Memorial, a rights group which documents Russia’s Soviet past, was arrested on Dec. 13, 2016. by police acting on an anonymous tip-off, days after someone had broken into his home and accessed his computer.

State prosecutors then accused him of taking pornographic photographs of his adopted daughter. Dmitriev said the photographs were not pornographic, but did involve nudity because he took them to document her health for social services.

The Novaya Gazeta daily said Thursday’s verdict was a rare piece of good news for those who believed in justice.

“The decision was unprecedented for Russian justice where the percentage of acquittals does not exceed the statistical margin of error,” it wrote.

“We take pleasure in simple things, in an ordinary fair court verdict of which there should be tens and hundreds of thousands in the country.”