Inseminating cattle in the veterinary clinic is permissible and does not come under the heading of “stud fees of a stallion”, which is prohibited
Question

What is the ruling on inseminating cows in veterinary clinics; is this regarded as coming under the heading of “stud fees of a stallion”?
Praise be to Allah.We do not think there is anything wrong with artificial insemination of cows in veterinary clinics. That does not come under the heading of “stud fees of a stallion” (charging fees for natural covering of the female animal by the male), which is prohibited. We have previously discussed this matter on our website, in fatwa no. 150367. and we do not see anything wrong with artificial insemination, for a number of reasons: 
Firstly: 
There is no report of any prohibition on insemination by means other than covering by a male. The basic principle concerning actions is that they are permissible so long as there is no report of any prohibition on them. 
Secondly: 
The work done by the veterinarian, the experience he has acquired and the time he has devoted to that are all services which it is permissible to pay fees for. Just as the veterinarian may be paid to treating animals and ridding them of defects and sickness, he may also be paid for undertaking the process of artificial insemination in his clinic. 
Thirdly: 
The proven prohibition on stud fees of a stallion is mentioned in the hadeeth of Ibn ‘Umar (may Allah be pleased with him): The Prophet (blessings and peace of Allah be upon him) forbade the stud fees of a stallion. Narrated by al-Bukhaari, 2284. This prohibition does not include the veterinarian at all; the prohibition refers specifically to when there is a stallion which is brought to cover the female, which is not applicable in the case mentioned in the question. 
Moreover, there is a clear reason for the prohibition, which was stated by the scholars who followed the apparent meaning of the report, because it is a case in which delivery of the service is not under the individual’s control, so it is more like renting out a runaway slave, as it is connected to the stallion or bull and his desire. The focus of the contract is the semen, which is something that cannot be subject to a contract, because there is ambiguity concerning it.
See al-Mughni by Ibn Qudaamah, 4/159 
All these problems which constitute reasons that make it disallowed are not applicable in the case of artificial insemination in the veterinary clinic by mechanical means, for example. In this case, it is possible to deliver what is required, which is the procedure and insemination, and the bull has nothing to do with this procedure. The contract is not about the semen; rather the contract is about the work and effort of the veterinarian, using the semen of the bull. The fiqhi principle states: something may be permissible as a secondary matter that is not permissible on its own. Ibn Hajar al-Haytami (may Allah have mercy on him) said: That which it is not permissible to rent or hire on its own may be permissible if it is secondary to another matter. See: az-Zawaajir, 1/382. Whether pregnancy occurs or not is not the focus of the deal here; rather the focus of the deal is doing the procedure, because pregnancy is not guaranteed and it is not permissible to make pregnancy the focus of the contract, so as to avoid the risk of ambiguity. 
Even though the Shaafa‘is stated that the prohibition applies to taking payment in return for covering by the stallion or bull, some of them stated that what is prohibited is hiring the male to cover the female, which is something that may not happen. The bull may or may not do it. But if one hires the owner of the bull to help him make sure that the bull covers the female, there is nothing wrong with that. 
It says in Hawaashi ash-Sharwaani ‘ala Tuhfat al-Muhtaaj, 4/292: 
From the above it is known that the scenario is hiring a person to ensure that covering occurs. If he hires him to make his stallion or bull cover one or more females, that is valid, as was stated by al-Qaadi, because his work is permissible and his work is usually clearly defined, and a particular stallion or bull may be identified in the contract, because different males are used for different purposes. If the male dies or it is not possible to make it cover the female, then the job is not done. But one may say that even though ensuring that covering occurs by the efforts of the owner, this could not be done unless the bull or stallion chooses to do it, and there is no guarantee that the owner will be able to make him do it. The response to that is that the owner is hired to do a specific job, which is to ensure that the male covers the female in the natural manner; even though the action of the stallion or bull is the intended goal, it is not the focus of the contract, thus the owner deserves to be paid, once covering has occurred, but if it does not occur, he does not deserve to get paid. End quote. 
And Allah knows best.