Hilchos Lashon Hara, chapter 3, section 7
Know also, an important, cardinal rule regarding these matters – judging favorably. If one sees a person who spoke or did something, whether between man and G-d, or between man and his fellow, and one can judge it favorably or unfavorably – if the person is G-d fearing one is obligated to judge him favorably even if it would be more logical to judge him unfavorably. If he is a regular person who is sometimes careful not to sin and sometimes sins, if the doubt is balanced, it is a mitzvah to judge him favorably. As the sages say, “If someone judges his fellow favorably, the Omnipresent will judge him favorably,” and he is included in the verse’s statement, “Judge your fellow righteously.” Even if the matter leans more to be unfavorable, it is very correct that one should regard the matter as doubtful and not decide unfavorably. If the matter leans more to be favorable and one judged him unfavorably, and thus went and denigrated him, besides transgressing, “Judge your fellow righteously,” one also transgress by speaking lashon hara.