The World Court has unanimously ordered Israel, accused by South Africa of genocide in Gaza, to take all necessary and effective action to ensure basic food supplies to the enclave's Palestinian population and halt spreading famine.
But Gaza's Hamas rulers said a ceasefire was needed to halt the humanitarian crisis.
The order from the International Court of Justice came as Israeli forces and Palestinian fighters battled in close combat around Gaza's Al Shifa Hospital, where the armed wings of Hamas said they attacked Israeli soldiers and tanks with rockets and mortar fire.
Judges at the court said the people in the coastal enclave face worsening conditions.
"The court observes that Palestinians in Gaza are no longer facing only a risk of famine (...) but that famine is setting in," the judges said in their order.
The new measures were requested by South Africa as part of its case that accuses Israel of state-led genocide in Gaza.
Senior Hamas official Basem Naim said the ruling did not go far enough and Israel must be ordered to end its military offensive to halt the suffering.
"We welcome any new demands to end this humanitarian tragedy in Gaza and especially in the northern Gaza Strip, but we hoped the court ordered a ceasefire as an absolute solution to all the miseries our people in Gaza are living through,” Naim told Reuters.
The UN Security Council voted on Tuesday to demand an immediate ceasefire and the immediate and unconditional release of all hostages. The United States abstained from, but did not veto, the vote.
There was no immediate comment from Israel's Foreign Ministry on the World Court ruling. Israel has said it is making efforts to expand access for humanitarian groups to Gaza overland, through air drops and by ship.
Israeli leaders have said Hamas can end the war by surrendering, freeing all hostages it holds in Gaza and handing over for trial those involved in the October 7 attack.
The Israeli army said it continued to operate around the Al Shifa Hospital complex in Gaza City after storming it more than a week ago. Its forces had killed around 200 gunmen since the start of the operation "while preventing harm to civilians, patients, medical teams, and medical equipment", it said.
In a televised statement, chief Israeli military spokesperson Rear Admiral Daniel Hagari said troops operating at the hospital killed Raed Thabet, a Hamas quartermaster whom he described as one of the group's 10 most senior members.