The Requirements to Be Considered a Tzaddik(Masechet Berachot Daf סא: Perek 9 Siman 222)

(condensed from Ein Ayah, Berachot 9:222)

Gemara: Rava said: People like us are average people. Abaye said to him: You are not giving people a chance.

Ein Ayah: Rava thought that the foundation of the determination of whether one is a tzaddik, a rasha, or an average person does not follow from how he acts in the final analysis, but by what thoughts enter his head. He thought that a tzaddik should be someone who only contemplates things that are good and proper. It is an average person who sometimes has thoughts that are negative, even if he is one who consistently overcomes those thoughts.

Abaye responded that those standards make it almost impossible for there to be a tzaddik. Even someone who is fully entrenched in goodness will have evil thoughts pass through his head. The power of the tzaddik is to be able to quickly dismiss these thoughts. Rather, according to Abaye, an average person is one whose evil thoughts are entrenched enough that he is not always able to distinguish between them, and therefore he may even decide sometimes based on the evil. However, one who is able to discern and make his decisions based on proper thoughts is a tzaddik.