He entered ihram with an ambiguous intention and on behalf of an unspecified individual, then he specified that individual. Is that valid?
Question

                Someone formed the intention to do Hajj on behalf of someone else, and entered ihram from the miqaat without specifying the person on whose behalf he was doing Hajj; rather he entered ihram for Hajj on behalf of someone else without specifying. Then after that, someone asked him to do Hajj on his behalf or on behalf of some other, specific person. Is it permissible to turn a general intention to do Hajj on behalf of an unspecified person into the intention to do it on behalf of a specific person?
Praise be to Allah.The fuqahaa’ differed concerning the one who enters ihram with an unclear intention, i.e., he intends to do it on behalf of someone else without specifying who that person is. The Hanbalis are of the view that it counts on his own behalf, because ihram can only be done on behalf of a specific individual.
The Hanafis and Shaafa‘is, and al-Qaadi and Abu’l-Khattaab among the Hanbalis, are of the view that it is valid to enter ihram on behalf of someone else without specifying who that person is, on condition that the one who does that specifies the person on whose behalf he is doing it before starting to do any of the actions of Hajj (tawaaf, sa‘i or standing in ‘Arafah).
If he does not specify someone and he starts to do any of these actions, then the Hajj is on his own behalf.
Ibn Muflih (may Allah have mercy on him) said: If he enters ihram on behalf of two people, it is Hajj on his own behalf, according to the consensus of the four imams, because it is not possible for him to do it on behalf of both of them, and there is nothing to suggest which of them takes priority. The same applies if he enters ihram on behalf of both Zayd and himself.
The same applies if he enters ihram on behalf of one of the two without specifying one of them, because ihram should be intended on behalf of a specific individual.
Al-Qaadi and Abu’l-Khattaab favoured the view that he may intend it on behalf of whichever of them he wishes, because it is valid to enter ihram on behalf of an unspecified person, so that he may specify one of the two later on.
The Hanafis said: It is valid because ihram is a means of achieving a goal, and what is ambiguous is valid as a means, provided that he makes it specific later on, and that is sufficient condition.
But if he does one circuit of tawaaf, or does sa‘i, or stands in’Arafah, before specifying the person on whose behalf he is doing it, then it is on his own behalf, because it cannot be deemed invalid, and it cannot be done on behalf of an unspecified individual.
End quote from al-Furoo‘ (5/386).
It says in Majma‘ al-Anhur (1/308): If he enters ihram with the intention of doing it on behalf of two people without specifying one of them, then he specifies one of them before starting to do the rituals, then that is valid according to both, because ihram is prescribed as a means to an end, and what is ambiguous is valid as a means, provided that it is made specific at some point (before starting to do the rituals). This is contrary to the view of Abu Yoosuf, who stated that it counts on his own behalf, because he is enjoined to be specific, and leaving it ambiguous is contrary to that. This is on the basis of analogy, such as if someone told him to do Hajj on his behalf, and someone else told him to do ‘umrah on his behalf, so he combined the two in one ihram; that is not valid, unless they both gave permission for that.
After starting the rituals, he cannot specify one of the two (and thus it counts on his own behalf only), according to scholarly consensus. End quote.
It says something similar in al-Hidaayah Sharh al-Bidaayah (1/179).
An-Nawawi (may Allah have mercy on him) said: If two people hired him to do Hajj on their behalf, or they told him to do that without paying a fee, and he entered ihram on behalf of one of them, without specifying which of them it was, then his ihram is valid for either of them, and he can decide which of them he wants, before starting to do any of the actions of Hajj.
This is our view and al-‘Abdari narrated it as the view of our madhhab. It was also the view of Abu Haneefah and Muhammad ibn al-Hasan.
Abu Yoosuf said: It counts on his own behalf.
End quote from al-Majmoo‘ (7/138).
Based on that, if this pilgrim specified the individual on whose behalf he was doing Hajj before starting to do tawaaf or standing in ‘Arafah – if he did not do tawaaf beforehand – then his Hajj counts on behalf of the person whom he specified.
Otherwise, it counts on his own behalf.
And Allah knows best.