According to Muslim jurists, when certain obligations fall into conflict with regard to a particular person or situation, a process of balancing the benefits and harms of both choices should be conducted and preference should be given to the obligation that brings about good most and repels evil most.

Answering your question, Sheikh Muhammad Saleh Al-Munajjid, a Saudi lecturer and author, stated,

First, according to the more correct opinion of the two opinions of Muslim scholars, Hajj is an immediate obligation. This means that Hajj becomes an obligation as soon as a Muslim becomes able to do it. Therefore, it is not permissible for able Muslims to delay Hajj without a legitimate excuse.

Second, migration from a non-Muslim country can be either obligatory or recommended, depending on the situation. If Muslims are able to practice their religion openly and are safe from temptation and seduction, then they do not have to migrate. But if they cannot practice their religion openly or if they fear temptations, then migration becomes obligatory.

If migration has become obligatory but a person does not have enough money for both migration and Hajj, then migration should be given precedence, because Hajj is obligatory only when one has money in excess of what is enough for his or her basic needs.

Obligatory migration comes on top of the list of one’s basic needs, so it takes precedence over Hajj. This is because delaying obligatory migration can affect a Muslim’s religious commitment. Meanwhile, Hajj may be delayed if there is a lawful excuse. So, obligatory migration should be given precedence, even at the time of Hajj.

If migration becomes necessary before the season of Hajj, then the Muslim has to do it, and when the season of Hajj comes, Hajj becomes obligatory if he or she can afford it.