All perfect praise be to Allah the Lord of the Worlds. May His peace and blessings be upon our Prophet Mohammad and upon all his family and companions.
Selling manure to be used as fertilizer for the soil and plants is amongst the needs that the jurists have deemed permissible. This is an exception to the Sharia maxim, "It is forbidden to sell impurities," because necessities render prohibited things permissible. However, some of our jurists (Shafie) said: "We don`t call this a sale transaction; rather, it is a termination of ownership right in exchange for a compensation, which is permissible."
It is stated in the Shafie book [Hashiyat al-Baijouri, vol.1/pp.441]: "It is permissible to terminate one`s ownership right in a filthy item in exchange for a compensation as this is similar to waiving one`s right in a job in exchange for a compensation. In such situation, the owner of the filthy item says: "I terminate my ownership right in exchange for the agreed compensation." The other person replies: "I accept." The same view is stated in [Hashiyat al-Bajirmi ala Shareh al-Khateeb, vol.4/pp.3.]
Hanafie scholars have approved of the this exception and stated that it is permissible to sell manure. They have actually stated: "Selling manure isn`t disliked; rather, it is permissible." {Raad al-Mohtaar, vol.5/pp.246}.
Moreover, according to the reliable opinion of the Hanabali Madhab, it is permissible to sell the manure of the animals whose meat is lawful to eat. And Allah the Almighty Knows Best.