Allah's Messenger (ﷺ) ordered us to kill dogs, and we carried out this order so much so that we also kill the dog coming with a woman from the desert. Then Allah's Apostle (ﷺ) forbade their killing. He (the Prophet further) said: It is your duty the jet-black (dog) having two spots (on the eyes), for it is a devil.
Allah's Messenger (ﷺ) ordered the killing of dogs and then said: what is the trouble with them (the people of Medina)? How dogs are nuisance to them (the citizens of Medina)? He then permitted keehing of dogs for hunting and (the protection of) herds.
In the hadith transmitted on the authority of Yahya, he (the Holy Prophet) permitted the keeping of dogs for (the protection of) herds, for hunting and (the protection of) cultivated land.
Ibn 'Umar reported Allah's Messenger (ﷺ) as saying He who kept a dog other than one meant for hunting or for watching the herd lost out of his deeds (equal to) two qirat every day.
He who kept a dog other than one meant for watching the herd or for hunting would lose every day two qirat of his good deeds. 'Abdullah and Abu Huraira also said: Or dog meant for watching the field.
He who kept a dog other than one meant for hunting or for the protection of the herd would lose two qirat of his deeds every day. Salim said: Abu Huraira (Allah be pleased with him) used to say: Or the dog meant for watching the field, and he was the owner of the land.