Praise be to Allaah.
Concerning the situation mentioned in the question, there has been a great deal of discussion amongst the scholars of the current age. Some say that it is permissible, some say that it is forbidden, and some say that we cannot comment either way. Among those who said that we cannot comment either way was Shaykh ‘Abd al-‘Azeez ibn Baaz (may Allaah have mercy on him). The researcher thought that the view of the majority of modern scholars is most likely to be correct, but subject to certain conditions, namely:
(a) urgent need, i.e., when it is not possible to achieve pregnancy by natural means
(b) the doctor dealing with the case should think it most likely that no harm will be caused by doing this procedure
(c) there should be no room for sperm (lit. lineages) to be mixed
The ruling on the case mentioned is the same as the ruling on a case where sperm is taken from a man and an egg from his wife, then the egg is fertilized in a test tube and returned to the uterus. The most correct view is that this is permissible, subject to the conditions mentioned above.