Objection 1. It would seem unlawful to judge. For nothing is punished except what is unlawful. Now those who judge are threatened with punishment, which those who judge not will escape, according to Matthew 7:1, "Judge not, and ye shall not be judged." Therefore it is unlawful to judge.
Objection 2. Further, it is written (Romans 14:4): "Who art thou that judgest another man's servant. To his own lord he standeth or falleth." Now God is the Lord of all. Therefore to no man is it lawful to judge.
Objection 3. Further, no man is sinless, according to 1 John 1:8, "If we say that we have no sin, we deceive ourselves." Now it is unlawful for a sinner to judge, according to Romans 2:1, "Thou art inexcusable, O man, whosoever thou art, that judgest; for wherein thou judgest another, thou condemnest thyself, for thou dost the same things which thou judgest." Therefore to no man is it lawful to judge.
On the contrary, It is written (Deuteronomy 16:18): "Thou shalt appoint judges and magistrates in all thy gates . . . that they may judge the people with just judgment."
I answer that, Judgment is lawful in so far as it is an act of justice. Now it follows from what has been stated above (1, ad 1,3) that three conditions are requisite for a judgment to be an act of justice: first, that it proceed from the inclination of justice; secondly, that it come from one who is in authority; thirdly, that it be pronounced according to the right ruling of prudence. If any one of these be lacking, the judgment will be faulty and unlawful. First, when it is contrary to the rectitude of justice, and then it is called "perverted" or "unjust": secondly, when a man judges about matters wherein he has no authority, and this is called judgment "by usurpation": thirdly, when the reason lacks certainty, as when a man, without any solid motive, forms a judgment on some doubtful or hidden matter, and then it is called judgment by "suspicion" or "rash" judgment.
Reply to Objection 1. In these words our Lord forbids rash judgment which is about the inward intention, or other uncertain things, as Augustine states (De Serm. Dom. in Monte ii, 18). Or else He forbids judgment about Divine things, which we ought not to judge, but simply believe, since they are above us, as Hilary declares in his commentary on Matthew 5. Or again according to Chrysostom [Hom. xvii in Matth. in the Opus Imperfectum falsely ascribed to St. John of the Cross], He forbids the judgment which proceeds not from benevolence but from bitterness of heart.
Reply to Objection 2. A judge is appointed as God's servant; wherefore it is written (Deuteronomy 1:16): "Judge that which is just," and further on (Deuteronomy 1:17), "because it is the judgment of God."
Reply to Objection 3. Those who stand guilty of grievous sins should not judge those who are guilty of the same or lesser sins, as Chrysostom [Hom. xxiv] says on the words of Matthew 7:1, "Judge not." Above all does this hold when such sins are public, because there would be an occasion of scandal arising in the hearts of others. If however they are not public but hidden, and there be an urgent necessity for the judge to pronounce judgment, because it is his duty, he can reprove or judge with humility and fear. Hence Augustine says (De Serm. Dom. in Monte ii, 19): "If we find that we are guilty of the same sin as another man, we should groan together with him, and invite him to strive against it together with us." And yet it is not through acting thus that a man condemns himself so as to deserve to be condemned once again, but when, in condemning another, he shows himself to be equally deserving of condemnation on account of another or a like sin.
Summa Theologica, II-II, Q. 60, A. 2.