I performed Hajj last year, praise be to Allah The Almighty. Please note that the Zakah of the money I used for Hajj was not paid although more than one lunar year had passed on it. The money was not with me for more than seven months out of the full lunar year as it was lent out to others. What is the ruling on my Hajj in such a case?
All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
It is not permissible to delay paying Zakah after a full lunar year has passed on it except with a valid excuse and doing this involves sin. Performing Hajj with money before paying the Zakah which is due on it is valid. However, scholars have held different opinions as to whether or not the pilgrim incurs sin for disposing of that money in addition to the sin of delaying paying Zakah.
The difference in the scholars' opinions regarding this matter is based on the difference on whether Zakah is in relation to the money itself or to the owner of the money. There are two opinions regarding this matter.
According to the first, this person is held sinful for disposing of the money whose Zakah is not yet paid while the other opinion is that he is not held sinful for doing so. The first opinion is the more correct one according to the Shaafi‘i scholars. An-Nawawi said, "Does the obligation of Zakah relate to the person or the wealth itself? There are two opinions: The later opinion, which is the correct one, is that it relates to the wealth itself and the former opinion is that it relates to the individual.”
Another group of scholars held that Zakah is in relation to the individual and not the wealth. Thus, it is permissible and valid for a person to dispose of his money through trade and such. However, he is held sinful for failing to pay its Zakah. Ibn Qudaamah from the Hanbali school of jurisprudence said, "It is permissible to dispose of the Nisaab (threshold amount) on which Zakah is due upon through trade, gifts and such and the person in charge of collecting the Zakah money is not entitled to cancel any such transactions."
Hence, your Hajj is valid and you have to pay the Zakah of your money as long as a full lunar year has passed on it regardless of whether the money was with you or as a debt that others owed you.
Allah Knows best.