Sahih Muslim Book 10, Hadith Number 3814.

Chapter : Riba (Usury).

Ibn Mughaffal reported: Allah’s Messenger (may peace be upon him) 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 keeping 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.