the indication that prayer is invalid in camel resting-places is the prohibition against praying in them. If you pray in one of them, you have done what the Messenger of Allah ﷺ prohibited, and that is an act of disobedience. An act of disobedience cannot become an act of obedience; therefore, the prayer is invalid.
If someone were to ask: His statement, “Pray in sheep pens,” is a command, and a command denotes obligation. Does this mean that I must look for sheep pens in which to pray?
The answer is: No. Here, the command denotes permissibility, because it comes in contrast to the prohibition of praying in camel resting-places. For this reason, the scholars say that a command issued after a prohibition indicates permissibility (1). Since one might suppose that, once prayer in camel resting-places had been forbidden, prayer in sheep pens would likewise be forbidden, he said: “Pray in sheep pens.” It is as though he said: Do not pray in camel resting-places, but you may pray in sheep pens.
The reason prayer is invalid in camel resting-places is that the Prophet ﷺ forbade it. For the believer, the Prophet’s ﷺ prohibition and his legislative command are the operative cause, as indicated by Allah’s saying:
“It is not for a believing man or a believing woman, when Allah and His Messenger have decided a matter, to have any choice in their affair.” [al-Ahzab: 36]
Thus, the believer says: “We hear and we obey.”
Further evidence for this is that Aisha was asked: “Why does a menstruating woman make up the fasts but not make up the prayers?” She replied: “This would happen to us, and we were commanded to make up the fasts but were not commanded to make up the prayers.” (2) Thus, she explained that the reason for this is the command.