Riyad as-Salihin (The Meadows of the Righteous)
by Imam Nawawi
261. Chapter: On the clarification of what lying is permitted
Know that lying, even if it is basically forbidden, is permitted in certain cases with certain preconditions which I explained in the Kitab al-Adhkar. In brief, words are a means to ends. If any goal which is praiseworthy can be obtained without lying, then it is forbidden to lie in it. If it can only be obtained by lying, then it is permitted to lie. If the goal is permissible, then the lie is permissible, and if the goal is mandatory, then lying is mandatory. If a Muslim is hiding from a wrongdoer who wants to kill him or take his property which he has hidden and a man is asked about him, it is mandatory to lie to conceal him. The same is true if he has a deposit and a wrongdoer wants to take it: he must lie to conceal it. It is more circumspect for him to use allusion and to employ expressions which are not lies in themselves although they give a false impression. If he actually lies, it is not forbidden in such a case.
Scholars find the permission to lie in this case in the hadith of Umm Kulthum who heard the Messenger of Allah, may Allah bless him and grant him peace, say, "The one who puts things right between people and produces (or says) good is not a liar." [Agreed upon]
Muslim's variant adds, "Umm Kulthum said, "I did not hear him make an allowance regarding anything that people say except in three cases: in war, putting things right between people, and what a man says to his wife and a wife says to her husband.