SLOVYANSK, Ukraine — When Denis Bigunov, a civil servant, recently returned to work after a long break, he found three prisoner’s hoods wrapped in masking tape stashed in his office at City Hall, sinister mementos left behind by the pro-Russian rebels who controlled this eastern Ukrainian city for nearly three months.

He donated the hoods to the local history museum “to remind people what really happened” here after masked gunmen seized control on April 12 and, cheered on initially by many residents, began a brutal drive to create a new order rooted in fanatical loyalty to Russia.

With the city now back in government hands and the Ukrainian military advancing steadily against other nearby settlements that had fallen earlier this year to the pro-Russian cause, Slovyansk has become a test of whether the central government in Kiev can both win on the battlefield and win back the loyalties of its rebellious east.

“We can’t just liberate these places by force of arms but need to change people’s thinking,” said Anton Gerashenko, an Interior Ministry official from Kiev who visited Slovyansk last week. He came to preside over the exhumation of corpses from a mass grave that he said had been left behind by the rebels before they fled south on July 5 to the city of Donetsk, which is still held by separatists.