In righteousness you shall judge your people.(Lev. 19:15)
[This means that] you should judge your friend favorably. (Shavuot 30a)

When you can judge your friend favorably, you will likewise be judged….

The Baal Shem Tov commented on the verse "Deliver me from all my transgressions; make me not the reproach of the despised" (Psalms 19:9), explaining that when you see a wicked person commit some despicable act or grievous sin, you should judge him favorably. He only did it because his passions overcame him, and he has a coarse physical nature, or he doesn't realize the seriousness of the crime. [You should think] these and similar thoughts. Then, you also save yourself from judgment; for seeing this low thing in your friend should make you realize that you share a similar trait, and that there are judgments and accusations upon you, as well. When you can judge your friend favorably, you will likewise be judged.

By not arousing judgment upon a sinner, who is overcome by his desires, you fulfill the verse "You shall not incline the judgment of your poor in his dispute" (Ex. 23:6). When trials and conflict overwhelm him (i.e. when he struggles against his own evil inclination) from the "waters of dispute" (Num. 20:13), i.e. evil and malicious waters, you should arouse favorable judgments upon him.

A person is never sentenced for his crimes until he first passes judgment upon himself….

Really, this is all a great test. For a person is never sentenced for his crimes until he first passes judgment upon himself. And since he will certainly not judge himself, they show him a person who did something similar. When he passes judgment upon the latter, he seals the judgment on himself, as well.

[Adapted by Eliezer Shore from Otzar HaYira, parashat Mishpatim, p. 193b (as found in Sefer Baal Shem Tov)
Reprinted with permission from The Baal Shem Tov Foundation - baalshemtov.com]