Judge Aaron Persky made a profoundly unpopular decision in June 2016 when he sentenced a Stanford swimmer convicted of sexual assault to six months in jail. Count us among the millions who were deeply disappointed, even outraged, upon learning of the punishment — especially after reading the victim’s eloquent 7,000-word statement that went viral on the Internet.

That ruling was the driving issue behind a campaign to recall Persky from the Santa Clara County Superior Court. That effort has qualified for the June 5 ballot. If successful, he would be the first California judge to be recalled since 1932.

Here is what should be the deciding question in the voters’ verdict: Did Persky follow the law?

He did.

One of the most sacred principles of a system guided by rule of law is that the judiciary must be insulated from the dictates of authoritarian leaders or even the passions of the populace, no matter how intense or justified. Judges must retain the independence to follow the law without fear of losing their jobs.

In the sentencing of Brock Turner, then a 20-year-old Stanford student, state law gave Persky wide latitude. Turner could have been sentenced to a maximum14 years in prison; the prosecution had recommended 6 years. However, the probation department, after reviewing various factors that included Turner being a first-time offender, recommended six months.

It is important to note that the California Commission on Judicial Performance reviewed the case and concluded in its 12-page report that Persky’s sentencing decision was within the “parameters set by law and was therefore within the judge's discretion.” It found no evidence of bias in the judge’s conduct.

Turner was released after three months, under a law that gives inmates credit for time served.

Again, we would not propose to defend a six-month sentence for a young man convicted of sexual assault on an intoxicated and unconscious woman behind a dumpster on campus. We, too, were moved by the account of the 23-year-old victim, known in court records as “Emily Doe,” who told Turner at sentencing: “You took away my worth, my privacy, my energy, my time, my intimacy, my confidence, my own voice, until today.”

The furor over the verdict led California legislators to move quickly to toughen the sentencing laws on sex crimes, including an expansion of the definition of rape to include all forms of non-consensual assault, not just “an act of sexual intercourse.” Gov. Jerry Brown signed those bills in September 2016.

This is the way the system should work. Don’t blame judges for following their discretion within the law. This recall effort is ill-advised and dangerous. Neither justice for defendants nor the concept of judicial independence is served if judges are guided by their anticipation of public reaction instead of the letter of the law.

If you don’t like a law, change it. In this case, California did.

This commentary is from The Chronicle’s editorial board. We invite you to express your views in a letter to the editor. Please submit your letter via our online form: SFChronicle.com/letters.