BEIJING — One morning in May, government officials assembled the 700 students of Ashi township’s middle school, in the southeastern Chinese province of Guizhou, for a lesson on the importance of abiding by the law. Rule No. 1, they said, was simple: If you break the law, you will be punished.

But as one teacher tells it, their actions that afternoon taught a different lesson: The rule does not apply to government officials.

A few hours after the speechifying, the teacher later said, the chief of Ashi’s land bureau, who had attended the school session, raped her. When she tried to bring charges the next day, she said, a police commander told her, “If he wore a condom, it isn’t rape.” Other officials pressured her to keep silent and urged her boyfriend to abandon her so she would lose courage, she said.

Only two months later, after the teacher posted an eloquent plea online and a newspaper reported her accusations, did officials take action. Heads have rolled. The accused has been arrested.