Is it acceptable to lie if your purpose is to avoid hurting someone?
There is a difference between lying—i.e. deliberately contravening the truth—and giving a misleading impression [Ar.ma’areed] which means saying something that ostensibly implies one meaning while intending another. This does not contravene the truth of the message; but the speaker intends a specific referent while the hearer understands something else.
One can resort to this manner of discourse to avert harm.
For instance, it has been narrated that when Muslims sought refuge with the Negus [king of Abyssinia] and he refused to return them to the disbelievers, he was accused by the Christians of renouncing his religion. The Negus wrote on a piece of paper, "There is no god but Allah and Mohammed is His slave and Messenger. Jesus is His slave and Messenger, born of Mary, conceived without a father." He then pinned the paper under his shirt over his heart and went to meet the Abyssinians who accused him of rejecting Christianity. "You abandoned our religion and claim that Jesus is a servant while [our religion teaches us] he is the Son of God." The Negus placed his hand over his heart (and the paper) and said, "I testify that Jesus was no more than this" meaning what he wrote on the paper. The Christians took him at his word and left him.
It has been said that it is acceptable to resort to ma’reed instead of lying. A group of scholars based this permissibility on the hadith which states the permissibility of lying in certain cases such as war, to reconcile between people, and avert harm.