In a Nutshell: It is permitted by the Hanafis to buy and sell dogs for a lawful purpose, e.g., hunting, guarding, guiding the blind and so on. Imam Malik permitted it regardless however the other schools of thought prohibit such buying and selling.
All however allow a price to be given for relinquishing control of a dog - which differs from a sale in that the one relinquishing control does not carry the usual responsibilities associated with a sale such as quality, fitness for purpose, delivery etc.
The Prophet (saw) said:
"Whoever keeps a dog, two Qirats (a huge portion) of the reward of his good deeds is deducted daily unless the dog is used for guarding a cattle or for hunting." (Bukhari and Muslim])
Abu Mas’ood al-Ansari narrated:
The Messenger of Allah (saw) forbade the price of a dog, the wages of a prostitute and the fee of a fortuneteller. (Bukhari 2083; Muslim 2930)
Abu Juhayfah said:
The Prophet (saw) forbade the price of a dog. (Bukhari 1944)
Abdullah ibn Abbas narrated:
The Messenger of Allah (saw) forbade the price of a dog, and if a person asked for the price of a dog, said to fill his hand with dust. (Abu Dawud 3021)
Abu Hurayrah narrated:
The Messenger of Allah (saw) said: "The price of a dog, the fee of a fortuneteller and the wages of a prostitute are not permissible." (Abu Dawud 3023)
Jabir Ibn Abdullah said:
The Messenger of Allah (saw) prohibited receiving payment for selling dogs except for those kept for hunting (Nisa'i)
It is reported Uthman gave twenty camels in compensation to a man for a dog he killed and from Ibn Amr ibn al-Aas about paying compensation for destroying a dog... (Nawawi, Sharh Muslim)
The majority of jurists have said selling dogs is impermissible basing their opinion on the hadith reported by Abu Mas'ud al-Ansari (ra) who said the Messenger (saw) prohibited receiving payment for the sale of dogs and the earnings of a prostitute and soothsayer.
Jurists stated that from among the conditions of a sale contract is the sold item must be pure; there is a scholarly agreement on the impure nature of dogs.
The prohibition on the price of a dog and the fact it is among the most evil of earnings and is something vile indicates that it is haram to sell dogs; the transaction is not valid and the price is not halal and the one who destroys it is not obliged to repay its value, regardless of whether the dog is trained or not, or whether it is one that it is permissible to keep or not. This is the view of the majority of scholars, including Abu Hurayrah, al-Hasan al-Basri, Rabee’ah, al-Awzaa’i, al-Hakam, Hammaad, al-Shaafa’i, Ahmad, Dawood, Ibn al-Mundhir and others. (Sharh Muslim)
The apparent meaning of the prohibition is that it is haraam to sell them. This is general in meaning and includes all dogs, trained and otherwise, whether it is permissible to keep them or not. This also implies that the one who destroys them is not obliged to repay their value. This is the view of the majority.
Ibn Qudamah said:
There is no dispute that sales of dogs are invalid, no matter what kind of dog it is. (al-Mughni)
Jurists like Imam Malik however permitted the trade in dogs regardless of whether there was a benefit or not.
The Hanafi jurists and others maintained a similar opinion permitting selling of dogs stipulated they were kept for lawful or beneficial purposes such as hunting, guarding, guiding the blind etc. They based their opinion on the hadith reported by Jabir Ibn Abdullah where the Messenger (saw) prohibited receiving payment for selling dogs except for those kept for hunting as recorded later by al-Nisa'a (who regarded this part of the hadith as munkar - a type of weak hadith - whilst others regarded it as acceptable).
Abu Hanifah said: "The sale of dogs which bring some benefit is permissible, and the one who destroys them must repay their value. Ibn al-Mundhir narrated from Jabir, Ata and al-Nakha’i that it is permissible to sell a hunting dog but not any other kind…" (Nawawi, Sharh Muslim)
"The [buying] and selling of dogs, cheetahs, elephants, monkeys and all types of carnivorous animals is lawful, even the buying and selling of a cat, as it hunts rats and other harmful vermin (pests), hence one benefits by it." (al-Durr al-Mukhtar & Radd al-Muhtar, Vol. 7, p. 505)
"The buying and selling of dogs, cats, elephants, cheetahs, falcons, kestrels and hawks is permissible" (Bahar Shari’at, Vol. 2, Part 11, p. 809)
The hadith of Muslim which states that the Prophet (saw) said, "The price of a dog is impure (khabeeth)" is explained by Abu Hanifa means it is not pure and is makrooh explaining the Prophet (saw) also used the same word for the earnings of one who does cupping which are permitted by all scholars. (Mulla Ali Qaari, Mirqaat - Sharh Mishkat, Vol. 6, p. 12).
The hadith which states the Prophet (saw) "Prohibited from the earnings of the dog", according to Hanafi scholars refers to a prohibition at a time when dogs were ordered to be killed. Later, seeking benefit from a dog was permitted. Ahadith narrated the Prophet (saw) ordered a man to pay 40 dirhams for killing a hunting dog and another pay a ram for having killed a watchdog.
Regarding the validity of the hadith, Ibn Hajar (rh) said:
"The narrators of this narration are trustworthy; and since it is permissible to keep a dog for the above purposes, then it is permissible to sell and buy it for the purposes for which it is permissible to keep dogs, and this view is closer to the truth."
The Egyptian body that issues rulings, Dar al-Ifta, states on their website:
To facilitate the matter, in Islamic law, owning or exchanging a dog for any lawful purpose must not be through a transaction involving a sale and purchase but through relinquishing control of it i.e. the person who owns the dog relinquishes control of it to someone else in return for a monetary compensation. In this case, the money is not considered a price for the dog but for its relinquishment.
This is not a sham deal; it is different from a sale in that as soon as the person who relinquishes control of an article receives the money, he is not obliged to guarantee the relinquished article or even its deliverability. On the other hand, in a sale, the seller continues to guarantee the sold article until the buyer takes possession of it.
The luminary Shafi’i scholar, al-Qalyubi, wrote in his meta-commentary on Sharh Al-Jalal Al-Muhalla (2/383), "It is valid to agree on a benefit such as that derived from a dog or dung; the money exchanged is in return for relinquishing control of the article and not in return for the derived benefit or the article’s possession."
The opinion of Hanafi jurists and others that it is lawful and there is no objection to trading in dogs (or other carnivorous animals) whether they be kept for hunting or any other lawful purposes is based on the opinion of Imam Abu Hanifah or on paying money in return for relinquishing control of a dog according to the opinion maintained by the majority of scholars.