Ruling on keeping a dog outside the house as a pet
Question

What is the ruling on keeping a dog outside the house as a pet? What is meant by the loss of two qirats of one’s good deeds – does it mean that it is forbidden (haram) or disliked (makruh)?
Praise be to Allah.Firstly:
It is not permissible to keep a dog as a pet only, and it makes no difference whether the dog is kept inside the house or in a separate place outside the house.
This is indicated by the report which was narrated by al-Bukhari (5060) and Muslim (2941) from Ibn ‘Umar, according to which the Prophet (blessings and peace of Allah be upon him) said: “Whoever keeps a dog, except a dog for hunting or herding livestock, two qirats will be deducted from his reward every day.” According to another version: “Whoever keeps a dog, two qirats will be deducted from his good deeds every day…” al-Bukhari (2154) and Muslim (2949).
An-Nawawi said:
Our companions and others are agreed that it is haram to keep a dog unnecessarily, such as if someone keeps it because he likes the way it looks, or to show off. This is prohibited, and there is no difference of opinion concerning that."(Sharh Sahih Muslim  1/448).
That is because dogs are lowly and dirty animals, and because of the harm and negative consequences involved in keeping them; for example, they keep the angels away from the place where the dog is; they scare and frighten others; they are impure; and are dirty.
If there is a need for that, because of some benefits and interests that are served, such as guarding sheep from the danger of wolves and thieves, or keeping them for farming purposes, or using them for hunting, then these benefits justify keeping a dog, and there is no blame on the one who does that."(Taysir al-‘Allam Sharh ‘Umdat al-Hukkam  2/209).
Please see also the answers to questions no. 33668 and 69777 .
Secondly:
Most of those who commented on this hadith are of the view that the Prophet’s words “two qirats will be deducted from his reward every day” indicate that it is haram.
None of the scholars disagreed with that, as far as we know, except Ibn ‘Abd al-Barr among the leading scholars of hadith, and the Maliki scholars. He was of the view that the hadith indicates that keeping dogs is disliked (makruh), but not haram.
Ibn ‘Abd al-Barr said:
This hadith indicates that keeping dogs is not haram, even if they are kept for purposes other than farming, herding and hunting, because the words “two qirats will be deducted from his reward every day” indicate that it is permissible, not prohibited, because it cannot be said of prohibited things that whoever does this thing, such and such will be detracted from his good deeds or from his reward. Rather, if it was prohibited, the Lawgiver would have prohibited it in clear terms, so that the Muslim would not do any such thing. Rather this wording indicates that it is disliked (makruh), not prohibited (haram)."(Al-Istidhkar al-Jami‘ li Madhahib Fuqaha’ al-Ansar  9/450).
This a view of Ibn ‘Abd al-Barr is a weak view, which more than one of the scholars have commented on.
Al-Hafiz al-‘Iraqi (may Allah have mercy on him) said: His view is strange, because our conclusion that it is haram is based on that detraction from the reward, for that indicates that he has done something that is prohibited, which nullifies the reward of some of his good deeds, just as the non-acceptance of prayers from one who drinks alcohol, a runaway slave and one who goes to a fortune teller or soothsayer (as mentioned in other hadiths) indicates that these actions are prohibited. The fact that they are prohibited is the reason why the reward for prayer is nullified in these cases.
And he said: The reason why the wording of the hadith indicates that it is prohibited is very clear, because detraction from reward can only come about because of the sin that one has committed."(Tarh al-Tathrib  6/173).
Al-Hafiz Ibn Hajar said: What is claimed, that it is not haram based on the argument that he stated, is not sound. Rather it is possible that the punishment could come in the form of no longer being enabled to do a qirat’s worth of righteous deeds that he used to do, when he did not keep a dog.
And it is possible that keeping a dog is haram, and what is meant by detracting from the reward is that the sin that results from keeping the dog is equivalent to one or two qirats of reward, so what is detracted from the reward of the dog owner’s righteous deeds is equivalent to the sin incurred by keeping the dog, which is one or two qirats."(Fath al-Bari  5/7).
And Allah knows best.