If one reads UN Security Council Resolution 1373, the mission did have some international legal basis.
$1:
Calling on States to work together urgently to prevent and suppress terrorist acts, including through increased cooperation and full implementation of the relevant international conventions relating to terrorism,
Pakistan can cooperate by letting said mission happen.
$1:
Reaffirming the principle established by the General Assembly in its declaration of October 1970 (resolution 2625 (XXV)) and reiterated by the Security Council in its resolution 1189 (1998) of 13 August 1998, namely that every State has the duty to refrain from organizing, instigating, assisting or participating in terrorist acts in another State or acquiescing in organized activities within its territory directed towards the commission of such acts,
Pakistan's harboring of Osama bin Laden kept al Quaida functioning with some central control, assisting attacks in Pakistan, Afghanistan, London, Madrid, etc.
$1:
Refrain from providing any form of support, active or passive, to entities or persons involved in terrorist acts, including by suppressing recruitment of members of terrorist groups and eliminating the supply of weapons to terrorists;
Passive is the key word here when considering Pakistan.
$1:
Deny safe haven to those who finance, plan, support, or commit terrorist acts, or provide safe havens;
Pakistan is guilty guilty guilty guilty guilty.