Britain's security services defend - rather than undermine - freedom and democracy, the head of MI5 has said.
Andrew Parker was being grilled alongside GCHQ director Sir Iain Lobban and MI6 chief Sir John Sawers in an unprecedented public hearing.
He said 34 terror plots had been disrupted since the 7 July, 2005, attacks in London.
The three men were quizzed on the work of their organisations by the Intelligence and Security Committee.
The committee of MPs and peers normally takes evidence from the security chiefs in secret.
But they have been under pressure to be more open after leaks by ex-US security contractor Edward Snowden revealed widespread spying by GCHQ and the US National Security Agency.
MI6 chief Sir John Sawers warned the politicians that "our adversaries were rubbing their hands with glee, al Qaeda is lapping it up" in the wake of the Snowden revelations, adding: "The leaks from Snowden have been very damaging, they've put our operations at risk".
GCHQ chief Sir Iain Lobban said activists in the Middle East and "closer to home" had been monitored discussing ways of switching away from communications they "now perceived as vulnerable".
He also suggested the leaks could help paedophiles avoid detection, and said the success of intelligence operations required the country's enemies to be "unaware or uncertain" of methods.
The Intelligence and Security Committee has already carried out a limited investigation into claims that GCHQ used the American National Security Agency's vast Prism programme, which gathers information from internet companies, to circumvent UK laws.
Sir Iain was asked about these claims, but said his agency acted within the law and rejected the idea that they were involved in widespread snooping.
He said: "We do not spend our time listening to the telephone calls or reading the emails of the majority. That would not be proportionate, that would not be legal, and we would not do it."
He said the type of people employed by GCHQ were focused on combating terrorism and criminals and would "walk out" if they were asked to spy on innocent people.
Andrew Parker, who handles agents within the UK, told the committee a total of 34 terror plots had been foiled since 2005 including "one or two" plots aimed at causing mass casualties. Most had been foiled as result of the intervention of the police and security services.
He said MI5 was aware of "several thousand individuals in this country who I would describe as supporting violent extremism or are engaged in it" and "almost all" of the plots had involved some of "these people".
He also warned about the growth of "terrorist tourism", where British nationals travel abroad for training before return to the UK to plot attacks, with the civil war in Syria currently proving a magnet for those seeking "jihadi" activity among groups linked to al Qaeda.
Committee chairman Sir Malcolm Rifkind began the 90 minute hearing - televised with a two-minute time delay to prevent the inadvertent release of sensitive secrets - by saying it was a "very significant step forward in the transparency of our intelligence agencies".
The agency chiefs explained what they saw their role as in a post-Cold War world and whether they were worth the £2bn in taxpayer money they receive each year.
'Not James Bond'
Mr Parker, who took over as head of MI5 earlier this year, said it was a "proportionate investment against the threats the country faces".
Responding to concerns raised by leaks by ex-US security contractor Edward Snowden, he said: "The suggestion that what we do is somehow compromising freedom and democracy - of course we believe the opposite to be the case.
"The work we do is addressing directly threats to this country, to our way of life and to the people who live here."
MI6 chief Sir John Sawers was quizzed about why the security services had failed to predict the fall of the Soviet Union, 9/11 and the Arab Spring.
He said that was not their job, telling the committee: "We acquire the secrets that other countries don't want us to know... we are not all-knowing specialists in what's going to happen next month or next year."
Both he and Mr Parker stressed that they would never condone or be complicit in the torture of terror suspects, but Sir John admitted the security services were not adequately resourced or trained to cope with the scale of the terror threat in the immediate aftermath of 9/11.
"It took us some time to adapt to the scale of the threat we faced," he told the committee, but they had "learned a huge amount over the last 12 years" and he was "satisfied" with the "rigorous compliance procedures now in place".
Sir John, whose agency runs spying operations around the world, said agents in the field did not operate in isolation "like James Bond" and there was round-the-clock support available to them if they needed it.
"We have a system to enable guidance to be issued from head office and if we don't feel clearly enough it falls one side of the line or the other - or the facts are just uncertain - then we will wake the foreign secretary up and ask him for a view one way or the other."
Documents leaked to the Guardian newspaper by Mr Snowden - who is currently in Moscow where he has sought sanctuary from the US - revealed that agencies are able to tap into the internet communications of millions of ordinary citizens through GCHQ's Tempora programme.
Although the committee cleared the agency of any wrongdoing in the 197 specific intelligence reports it looked at, it is now undertaking a wider inquiry into whether the laws governing surveillance are adequate for the internet age.
Sir Tim Berners-Lee, who created the world wide web, has said encryption cracking by UK and US spy agencies is "appalling and foolish".
Journalist Glenn Greenwald, who worked with Mr Snowden on stories for the Guardian about spying by the National Security Agency and GCHQ, said the Parliamentary system had, so far, failed to hold Britain's intelligence agencies to account.
"There was a huge suspicion-less system of mass spying that the British people and the American people had no idea had been built in their name and with their money," he said.
But he added: "I believe that that system can bring about real accountability if there's the political will."
Sir David Ormand, former head of GCHQ, earlier defended the closeness of Britain's intelligence relationship with the US, telling BBC Radio 4's Today programme: "We have the brains. They have the money. It's a collaboration that's worked very well."
Asked why there had been such a fierce debate about the Communications Data Bill, dubbed the "snooper's charter" by critics, when GCHQ was already gathering large quantities of data covertly, he said the agency was "primarily a foreign intelligence agency" and the proposed legislation concerned British data.
He added: "You shouldn't be looking to GCHQ to provide what can very much more cheaply and easily provided by the internet service providers. That requires legislation and Parliament got itself in a bit of a tangle over the details of that legislation."
Sir David also dismissed Sir Tim Berners-Lee's criticisms, telling BBC Breakfast he thought the scientist was "probably exaggerating for effect, in order to get his point across and fire a shot across the bows of the intelligence agencies".