A US district judge in New York ruled on Friday that controversial telephone surveillance by the National Security Agency was lawful and a vital component of the war on Al-Qaeda.