from Qatādah, on the authority of Anas:
“The Prophet—may Allah bless him and grant him peace—sternly forbade drinking while standing.”
Qatādah said: “We asked, ‘What about eating?’ He replied, ‘That is worse and more reprehensible.’”
The hadiths permitting it include the report in the two Sahīh collections from ʿAlī and Ibn ʿAbbās:
“The Prophet—may Allah bless him and grant him peace—drank Zamzam water while standing.”
Al-Bukhārī also relates from ʿAlī that he drank while standing in the public square of Kufa. He then said:
“Some people disapprove of drinking while standing, yet the Messenger of Allah—may Allah bless him and grant him peace—did as I have just done.”
A report concerning this hadith of ʿAlī states that the water was from Zamzam, as related in the hadith of Ibn ʿAbbās. This took place during the Hajj, when the people there were circumambulating the Kaʿbah, drinking from Zamzam, drawing water, and asking him questions. There was no place to sit. Moreover, this occurred shortly before his death. This and similar circumstances are therefore exceptions to that prohibition.
This accords with the principles of Islamic law: something prohibited becomes permissible when there is a need. Indeed, things more strictly prohibited than this become permissible when there is a need. Even substances forbidden to eat or drink, such as carrion and blood, become permissible out of necessity. As for things whose direct use is forbidden despite their being pure—such as gold and silk—their use becomes permissible when there is a need.
The prohibition here concerns a manner of eating and drinking. It is therefore less stringent than the prohibition against drinking from gold and silver vessels or wearing gold and silk, for these carry a threat of punishment. Yet even these are permitted when there is a need, so this is all the more deserving of such permission. And Allah knows best.