We examine the link between the penalties used to punish convicted criminals and judicial prejudice against defendants. In our model, agents choose to commit crimes if their privately observed utility from doing so is high enough. A crime generates noisy evidence, and defendants are convicted when the realized amount of evidence is sufficiently strong to establish the probability of guilt beyond a fixed threshold. We show that if convicted offenders are incarcerated, poorer individuals face a strong prior prejudice in trials and are therefore convicted with less evidence than richer individuals. At the same time, they commit crimes more frequently. Penalties such as monetary fines can eliminate this bias, but may also reverse it. We fully characterize the penalty schedule that guarantees an unbiased equilbrium. We extend the model such that agents also differ in characteristics such as race or gender. We show biased outcomes (targeted at subgroups of the population) may still exist, even if all members of the population are ex-ante alike in their economic characteristics.