The boss of MI5 has said he supports new powers allowing security services to look at electronic communications as he warned terrorist plotting against the UK is at its highest for nearly four decades.
British MPs will debate the measures when the Communications Data Bill comes before parliament.
In the first live broadcast interview by any head of the British security services, Andrew Parker said it was important that MI5 should work within a "transparent" legal framework.
The internet and new technologies were providing new difficulties to MI5 and the agency's ability to deal with them, Mr Parker told the BBC.
He said: "Because of the threat we face and the way the terrorists operate and the way we all live our lives today, it is necessary that if we are to find and stop the people who mean us harm, MI5 and others need to be able to navigate the internet to find terrorist communication.
"We need to be able to use data sets so we can join the dots, to be able to find and stop the terrorists who mean us harm before they are able to bring the plots to fruition.
"We have been pretty successful at that over recent years, but it is becoming more difficult to do it as technology changes faster and faster."
The spy boss insisted his agency was not interested in "browsing through the private lives" of the general public.
"The important thing to say is that we focus on the people who mean us harm," he said.
"We do not have population-scale monitoring or anything like that."
Mr Parker, who played down worries about Islamist militants posing as refugees to enter Europe, said internet companies had a responsibility to share information about potential threats.
"It is in nobody's interests that terrorists should be able to plot and communicate out of the reach of any authorities with proper legal power.
"Some of the social media companies operate arrangements for their own purposes under their codes of practice, which cause them to close accounts sometimes because of what is carried.
"I think there is then a question about why not come forward? If there is something that concerns terrorism, or child sex exploitation or concerns some other appalling area of crime, why would the company not come forward?"
Mr Parker suggested there should be "international agreement and arrangements whereby companies have a confident basis on which to co-operate with agencies like mine and with the police in order to protect society and their customers".