King Yannai (deservedly so) gained his share of enemies. His wife was worried that after Yannai’s demise revenge would be taken on her children. Yannai told her that she should not fear the Perushim, as they are just, and would not harm innocent children, nor the Tzedukim, who were his friends, but only the hypocrites whose deeds are like those of Zimri and seek reward like Pinchas. (Sotah 22b)
Certainly Zimri was rotten, and Pinchas righteous, but Zimri’s action was public. How does this connect with hypocrisy? Maharsha was bothered by this question and concludes that the Gemara was simply using 2 opposites.
I saw an interesting explanation in a sefer this week, (don’t remember the name, and I’m not quoting exactly). At the end of Balak the Jews sinned direly with the daughters of Midyan. There was Avodah Zara in addition to Giluy Arayot (Rashi). Zimri came along and claimed that he was doing something positive by disconnecting these two terrible sins. He was actually saving the people from Avodah Zara!
In fact, he was a phony. His motivation was to have an affair with the princess. Sinning, while purporting to do something positive, is hypocrisy par excellence. Hence the example from Gemara Sotah.
We must be wary before accusing others of hypocrisy (as inconsistent behavior is often the result of spiritual weakness, not necessarily fakeness). Unfortunately, though, it exists too much, and must be recognized and eradicated.