This is recorded in Deuteronomy 25:1-3:
If there is a dispute between men and they go to court, and the judges decide their case, and they justify the righteous and condemn the wicked, 2 then it shall be if the wicked man deserves to be beaten, the judge shall then make him lie down and be beaten in his presence with the number of stripes according to his guilt. 3 He may beat him forty times but no more, so that he does not beat him with many more stripes than these and your brother is not degraded in your eyes.
A few observations can be made about this passage. First, there was a trial. This was not a lynch mob. It was civilized and supervised by a judge. Second, this was a maximum penalty –not the minimum penalty. For maximum offenders, men could get 40 lashes, but no more. Third, there was a limit on the lashes, so that “your brother is not degraded in your eyes.” Even in judgment, there is a concern for “over doing it.” Fourth, when we compare this with the ancient Near East, we find considerable differences. Copan writes,
For certain crimes, Hammurabi’s code insisted that the tongue, breast, hand, or ear be cut off. One severe punishment involved the accused being dragged around a field by cattle. In ancient Egyptian law, punishments included cutting off the nose and the ear.
Besides punishments such as cutting off noses and ears, ancient Egyptian law permitted the beating of criminals (for, say, perjury or libel) with between one hundred and two hundred strokes. In fact, a one-hundred-stroke beating was the “mildest form of punishment.