According to majority of the scholars spending the night at Muzdalifah is obligatory; even some of them view that it is a rukn (constituent).

However, the scholars have differed about the amount of time necessary to spend in Muzdalifah. The Shafi`ites and Hanbalites schools view that it is obligatory to spend at least a moment in Muzdalifah after the second part of the night of standing at Arafa. Spending the night, thus, is not necessary. It is just enough to pass through it.

Accordingly, if you happened to enter the boundaries of Muzdalifah even for a moment between midnight and dawn, then you have fulfilled the duty. But if you could not enter Muzdalifah due to over crowdedness, then you are obligated to do nothing as obligations are remitted in case of excuses. Allah almighty said: “Allah never burdens a soul beyond its capacity” [al-Baqarah 2:286]