Rashi on Numbers 14:24:1:
A different spirit (intention)
"Two spirits. One verbal and another in his heart. To the spies he said, "I am with you regarding your counsel", but in his heart he wished to say the truth. By this, he had the strength to quiet them (the co-spies) as stated (Numbers 13:30) "Kalev silenced them". Since they thought that he would say as they did. This is what is meant when it says in Joshua 14:7, "And I answered him word as was in my heart" - and not according to what was in my mouth."
This implies that he lied / deceived his co-spies.
Generally, the Torah forbids lying or deceiving others. Why was he allowed to do so in this case? Please support answer by citing halachic principle showing that this was an exception to the prohibition.