Thousands of Islamist extremists in the UK see the British public as a legitimate target for attacks, the director general of MI5 has warned.
Andrew Parker was making his first public speech since taking over as head of the UK Security Service in April.
Al-Qaeda and its affiliates in Pakistan and Yemen present "the most direct and immediate threats to the UK," he said.
He also warned of the damage done to British security by the leaking of classified documents from GCHQ.
Addressing the Royal United Services Institute in Whitehall, Mr Parker added the security services must have access to the many means of communication which terrorists now use.
He also revealed some of the fears and frustrations his service was experiencing over both the advances in technology, and those who leak government secrets into the public domain.
Intelligence officials in both the US and Britain have been absolutely dismayed at the wealth of secret data taken by the former CIA contractor Edward Snowden when he fled to Russia.
Some 58,000 of the files are from GCHQ, whose intelligence, Mr Parker said, had played a vital role in stopping many UK terrorist plots over the past decade.
Without mentioning Mr Snowden by name, he said ''it causes enormous damage to make public the reach and limits of GCHQ techniques".
Doing this, he added, handed the advantage to the terrorists.
He warned that terrorists now had tens of thousands of means of communication "through e-mail, IP telephony, in-game communication, social networking, chat rooms, anonymising services and a myriad of mobile apps".
Mr Parker said it was vital for MI5 - and by inference its partner GCHQ - to retain the capability to access such information if the Security Service was to protect the country.
However, some have argued that Snowden's revelations, which were published in the Guardian newspaper, have not harmed Britain and, in fact, opened a debate on the balance between privacy and security.
Henry Porter, a columnist with that newspaper's sister title the Observer, said: "The people who released and let go of these documents, of course, were the NSA in America.
"That's where the leak took place and we haven't published anything which jeopardised the security of this country."
In an interview with BBC Radio 4's Today programme, he said: "What we have done is shown how much surveillance we are under; legitimately under the laws that have been passed by this government."
A Guardian News & Media spokesman said: "A huge number of people - from President Obama to the US Director of National Intelligence, James Clapper - have now conceded that the Snowden revelations have prompted a debate which was both necessary and overdue.
"The President has even set up a review panel and there have been vigorous discussions in the US Congress and throughout Europe
"Such a debate is only worthwhile if it is informed. That is what journalism should do."
But Mr Parker warned that threats to the UK are growing more diverse and diffuse. And he warned: "It remains the case that there are several thousand Islamist extremists here who see the British public as a legitimate target."
He explained that "knowing of an individual does not equate to knowing everything about them".
"Being on our radar does not necessarily mean being under our microscope," he said.
"The reality of intelligence work in practice is that we only focus the most intense intrusive attention on a small number of cases at any one time.
"The challenge therefore concerns making choices between multiple and competing demands to give us the best chance of being in the right place at the right time to prevent terrorism."
Mr Parker added: "We are not perfect, and there are always things we can learn, do better and sharpen up on."
With 30 years in MI5, Mr Parker was previously deputy director general and before that director of its counter-terrorism division at the time of the London bombings in 2005.
'Stopped at airports'
In his speech, he named al-Qaeda and its affiliates in south Asia and the Arabian peninsula as presenting "the most direct and immediate threats to the UK".
By that he meant primarily its elements in Pakistan and separately in Yemen, from where al-Qaeda has three times succeeded in smuggling explosives past security on to planes in the last four years.
Referring to the ongoing conflict in Syria, he said a growing proportion of MI5's casework concerned individuals from the UK who had travelled to fight there.
He said extremist Sunni groups in Syria were aspiring to attack Western countries.
This has long been a concern of Western governments - that British-based jihadists will one day return from the killing fields of Syria and turn their new-found skills on the population back home.
A number of people have been stopped at airports and some have been arrested on suspicion of terrorism.
"For the future, there is good reason to be concerned about Syria," he said.
Mr Parker said 330 people had been convicted of terrorism-related offences in Britain between 11 September 2001 and 31 March 2013.
He added that in the first few months of this year, there had been four major trials related to terrorist plots.
Chillingly, he reminded the public that these included plans for a 7/7-style attack with rucksack bombs, and named two other plots.
There were guilty pleas in each case, he said, with 24 terrorists convicted and sentenced to more than 260 years in jail.
In conclusion, Mr Parker said he did not believe the terrorist threat was any worse now than before. But it was "more diffuse, more complicated, more unpredictable".