Israel has formally banned the main United Nations aid agency for Palestinian refugees from operating on its territory despite heavy diplomatic backlash.